In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "what is the use of the JavaScript array", the content of the explanation is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "what is the use of the JavaScript array" bar!
An array is an ordered collection of values. Arrays are untyped in JavaScript: array elements can be of any type. Create array methods, literals, and constructors.
Var count= [1 undefinded 3]; / / 3 elements, with undefindevar udefs= [,] in the middle; / / 2 undefinded elements, allowing an optional comma as the ending var a=new Array (10); / / an array of size 10
Each array has a length property, which is different from regular objects.
Array method
Join () converts all elements in the array into strings concatenated reverse () returns the inverted array sort (fn (afort b) {}) sorts alphabetically by default, the first parameter should return a value less than 0 concat () concatenates the new element and returns a new array slice (start,end) returns a fragment of the specified array [start,end) If a negative number means to insert or delete elements push () and pop () relative to the position of the last element splice (pop), add and delete elements unshift () and shift () from the back of the array, and add or delete elements ECMAScript5 from the front of the array.
ForEach (fn) traverses the array from beginning to end, calling the specified function map (fn) calls each element of the array to pass to the specified function, and returns an array filter (fn). The array element returned is a subset of the calling array, and the transfer function is used to determine whether true or falseevery (fn) is returned only if the decision function is called on all elements in the array. True is returned. Return truesome (fn) if at least one element returns true, return truereduce (fn,initVal) use the specified function to combine the array elements to generate a single value reduceRight () in the order from right to left reduceindexOf () returns to find the first element lastIndexOf () returns to find the last element
Array type
Method Array.isArray () in ES5
Var isArray = Function.isArray | | function (o) {return typeof o = "object" & & Object.prototype.toString.call (o) = "[object Array]";}
Array objects have the following properties:
(1) automatically update the length attribute when new elements are added
(2) set length to a small value to truncate automatically
(3) inheriting some useful methods in Array.prototype
(4) its class attribute is "Array"
Think of an object with a numerical value of length and a corresponding non-negative integer attribute as a type of array.
Strings in JavaScript can be similar to read-only arrays
Array.join = Array.join | | function (aForce sep) {return Array.prototype.join.call (aForce sep);} Array.join ({"0": "a", "1": "b", length:2}); s = "javascript"; Array.join (s, "") / / javascript Thank you for your reading, the above is the content of "what is the use of JavaScript array". After the study of this article, I believe you have a deeper understanding of the use of JavaScript array, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.