In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use numbers to index arrays in JavaScript". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use numbers to index arrays in JavaScript.
Many programming languages allow names to be used as indexes on arrays.
An array that uses a name as an index is called an associative array (or hash).
JavaScript does not support indexing arrays with names, only numeric indexes are allowed.
Example
Var person = []
Person [0] = "John"
Person [1] = "Doe"
Person [2] = 46
Var x = person.length; / / person.length returns 3
Var y = person [0]; / / person [0] returns "John"
In JavaScript, objects use the name as the index.
If you use the name as the index, JavaScript redefines the array as a standard object when accessing the array.
After doing this, the methods and properties of the array can no longer be used, otherwise an error will occur:
Example
Var person = []
Person ["firstName"] = "John"
Person ["lastName"] = "Doe"
Person ["age"] = 46
Var x = person.length; / / person.length returns 0
Var y = person [0]; / / person [0] returns undefined
At this point, I believe you have a deeper understanding of "how to use numbers to index arrays in JavaScript". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.