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 introduces you how to understand the basis of javascript object-oriented technology, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Array
As we have mentioned, an object is a collection of unordered data, while an array is a collection of ordered data, the data (elements) in the array are accessed through an index (starting at 0), and the data in the array can be of any data type. Arrays themselves are still objects, but because of their many properties, arrays and objects are usually distinguished from pairs (Throughout this book, objects and arrays are often treated as distinct datatypes.This is a useful and reasonable simplification; you can treat objects and arrays as separate types for most of your JavaScript programming.To fully understand the behavior of objects and arrays, however, you have to know the truth: an array is nothing more than an object with a thin layer of extra).
Functionality. You can see this with the typeof operator: applied to an array value, it returns the string "object". Section7.5).
You can use the [] operator to create an array, or use the Array () constructor to new one.
Js code
Var array1 = []; / / create an empty array var array2 = new Array (); / / create an empty array array1 = [1, "s", [3Power4], {"name1": "NAME1"}]; / / alert (array1 [2] [1]); / / 4 access array element alert (array1 [3] .name1); / / NAME1 access object alert (array1 [8]) in the array; / / undefined array2 = [,] / / if no value is entered, only a comma is entered, then the element at the corresponding index is undefined alert (array2.length); / / 3 alert (array2 [1]); / / undefined
When you use new Array () to create an array, you can specify a default size, where the value is undefined at this time, and you can assign them later. However, the length of the array in javascript can be changed arbitrarily, and the contents of the array can also be changed arbitrarily.
So the length of this initialization actually has no binding effect on the array. For an array, if you assign a value to an index that exceeds its length, the length of the array will be changed, and a undefined will be assigned to the index that is not assigned. See the example below.
Js code
Var array = new Array (10); alert (array.length); / / 10 alert (array [4]); / / undefined array [100] = "100th"; / / this operation changes the length of the array and sets the value corresponding to the 10-99 index to undefined alert (array.length); / / 101alert (array [87]); / / undefined
You can use the delete operator to delete the elements of the array. Note that this deletion only sets the element of the array at that location to undefined, and the length of the array does not change. We have used the length attribute of the array. The length attribute is a read / write property, which means that we can change the length of the array at will by changing the length attribute of the array. If length is set to a value less than the length of the array, values in the original array whose index is greater than length-1 will be deleted. If the value of length is greater than the length of the original array, the value between them is set to undefined.
Js code
Var array = new Array ("N1", "N2", "n3", "N4", "N5"); / / an array of five elements var astring = ""; for (var item0; I)
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.