js--the difference between arrays, = =, and = =

Source: Internet
Author: User

How to create an array:

1)

<script type= ' text/javascript ' >    varnew Array (1,2,3,4, ' abc ', 3)</script >

2) (this is actually used in many, high efficiency)

<scripts type= ' text/javascript ' >    var aRr02 = [All-in-all, ' SD ']; </script>

Operation:

1) Gets the number of members of the array:

Aleart (Arr02.length)

2) Popup array contents (PIN starting from 0)

Aleart (Arr02[3])

3) Connection string: Join ()

var str1 = Arr02.join ("-")var str2 = Arr03.join ("")

4) Add Delete member from the back of the array: Push (), pop ()

Arr02.push ("a")
Arr02.pop ();

5) Add Delete member from front of array: Unshift (), Shift ()

Arr02.unshift (' a '); Arr02.shift ();

6) Invert the array: reverse ()

Arr.reverse ();

7) Returns the index value of the first occurrence in the array element: IndexOf ()

var aRr2 = [' A ', ' B ', ' C ', ' d ', ' A ', ' B ', ' C ', ' d ' ]; var num = arr2.indexof (' B '); alert (num); // pop up 1

8) Add or remove elements from the array: Splice ()

Arr2.splice (2,1); alert (ARR2)// start deleting 1 elements from the subscript 2 element
Arr2.splice (2,1, ' e '); alert (ARR2)//start by deleting 1 elements from subscript 2 and inserting e into the element labeled 2 here

Two-dimensional arrays:

var aRr03 =[[1,2,3],[' A ', ' a ', ' d '],[true]]

The difference between = = and = = =:

= = Two data to be compared before being judged equal to the same data type

= = = Does not convert the data type, directly compared, if the data type is different, then this judgment must be unequal.

js--the difference between arrays, = =, and = =

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.