JS Reference type Learning

Source: Internet
Author: User

Today is the first day to write a blog!

It's so hard to understand what kind of feeling it is. Tt,c++ and Java are not the foundation.

Summary:

1: Object is a value of reference type

2.Object type (base type)

Methods of accessing properties: Person.name;

person["name"]//for property names with illegal characters

3.Array Type:

The A.length property is not just readable and can be used to add or remove items.  Eg:var Num=[red,blue,green];  color.length=2; Alert (color[2]);//undifined

B. Detecting array: instanceof array. or Array.isarray

The C.tostring method returns a comma-delimited string------------the Color.join ("|")//"Red|blue|green" default comma. ------------------valueof Returns an array

D.lifo and FIFO

Push (), pop (), shift () front end add unshift () front end delete;

Eg:var colors=new Array ();

var count=colors.unshift ("Red", "green");

Count=colors.unshift ("Black")//black,red,green

E. Reorder reverse () reverse order; sort () compares a string to accept a comparison function. The first parameter should return a negative number before the second, returning 0 as the same, or a positive number

function Compare (value1,value2) {

return value2-value1; Positive order

}

F. Operation Method Concat ()//stitching does not affect the original array

Slice () Eg:var colors=["Red", "green", "blue", "yellow", "purple"] Colors.slice (1,4)//green,blue,yellow Baotou not wrapped tail

Splice () Eg:var colors=["Red", "green", "Blue"] colors.splice ("Red", "purple")//red red purple;

G. Location method: IndexOf lastIndexOf not found return-1, will use = = =;

H. Iterative methods, the values of the array are not modified every filter ForEach map some

I. Attribution method: Reduce reduceright//start with the last item

eg var values[1,2,3,4,5]; var sum=values.reduce (function{(Prew,cur,index,array)

Return prew+cur})//sum=15;

4.Date type

5.RegExp type g: Global----------I: Ignore case mode--------------m multiline mode (\ escaped)

  

  

JS Reference type Learning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.