JavaScript Array Learning

Source: Internet
Author: User
Tags javascript array

First of all, thanks to dash , I don't have to look around for documents anymore.

Thanks again for the eclipse, let me see the world's beauty

Okay, let's get to the point.

Note All My learning experiences are based on ECMASCRIPT5.

IE9 prior to the browser is not responsible

The JavaScript array is a fun object

How to test her? First of all, instanceof is a good way.

if (value instanceof Array) {}

But according to JavaScript high-level programming says this if a person reconstructs the array function you're done.

So

if (Arrays.isarray (value)) {}


Now we're going to construct the

But what's the point of doing that?

Actually, I'm concerned about the same type of construction.

var arr1 = [];var arr2 = new Array (), var arr3 = Array (); alert (typeof arr1); alert (typeof arr2); alert (typeof ARR3);

Okay, it's all object types.

We all know there's a length attribute in the array, so is she reliable?

var fruits = [];fruits.push (' banana ', ' apple ', ' peach '); Console.log (fruits.length); 3fruits[5] = ' mango '; Console.log (fruits[5]);  ' Mango ' console.log (object.keys (fruits)); [' 0 ', ' 1 ', ' 2 ', ' 5 ']console.log (fruits.length); 6

It's only 4 elements that return 6.

Now I'm trying to modify the length property

Fruits.length = 2;console.log (Object.keys (fruits)); [' 0 ', ' 1 ']console.log (fruits.length); 2

What about my previous data?

Look at Array.Length, it's actually writable.

Two effects

Loop array similar to foreach

Eliminate unwanted arrays ... You should change it.

JavaScript Array 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.