In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to define arrays in javascript. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
The method of defining array in javascript: 1, use "var array name = [values list]" statement; 2, use "var array name = new Array (values list)" statement; 3, use "var array name = new Array (array length value); array name [subscript] = value;" statement.
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
Define using array direct quantities
Syntax format for array literals: contains multiple lists of values in square brackets, separated by commas.
Var array name = [values list]
If the values list can be empty, an empty array is created.
Example:
Var a = []; / / empty array var a = [1, true, "0", [1Magi 0], {XRX 1djj0}]; / / an array containing specific elements
Define by using the constructor
When you use the new operator to call a function of type Array (), you can construct a new array.
Var array name = new Array (); / / empty array var array name = new Array (values list); / / real array
If you pass a numeric parameter to Array (), the parameter value is equal to the attribute value of the array length, and you can define the length of the array, that is, the number of elements contained.
Var a = new Array (5); / / an array of specified length
At this point, the default value of each element is undefined, which can be initialized by assigning a value to each element:
This is the end of the article on "how to define arrays in javascript". I hope the above content can be helpful to you so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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: 248
*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.