In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about what JScript objects mean. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The Jscript object is a collection of properties and methods. A method is a function that is a member of an object. A property is a value or set of values (in the form of an array or object) that is a member of an object. Jscript supports four types of objects: internal objects, generated objects, host-given objects (such as window and document in Internet browsers), and ActiveX objects (external components).
An object as an array
In Jscript, objects and arrays are treated in almost the same way. Objects and arrays can be assigned any value, but in fact arrays are just a special kind of object. The difference between an array and an object is that the array has a "wonderful" length property, while the object does not. This means that one element of the array can be assigned a larger value than the other elements. For example, myArray [100] = "hello", and then the length property is automatically updated to 101 (new length). Similarly, if you modify the length property of an array, elements that are no longer part of the array are deleted.
All objects in Jscript support the "expando" attribute or those that can be dynamically added and deleted at run time. These properties can have any name that contains a number. If the name of an attribute is a simple identifier, you can add a period after the object name, for example:
Var myObj = new Object ()
/ / add two expando attributes, name and age
MyObj.name = "Fred"
MyObj.age = 42
If the attribute name is not a simple identifier, or if you don't know it when you write the script, you can use any expression in square brackets to index the property. The names of all expando attributes in Jscript are converted to strings before being added to the object.
Var myObj = new Object ()
/ / add two words that cannot be written in object.property
The expando attribute in the / / method.
/ / the first property contains invalid characters (spaces)
/ / so it must be written in square brackets.
MyObj ["not a valid identifier"] = "This is the property value"
/ / the second expando name is a number
/ / so it must also be written in square brackets.
MyObj [100] = "100"
The traditional practice is to assign a numeric index to an array element that starts with 0. These array elements interact with the length attribute. However, since all arrays are also objects, the expando property is also supported. Note, however, that the expando property does not interact with the length property in any way. For example:
/ / an array of three elements
Var myArray = new Array (3)
/ / add data
MyArray [0] = "Hello"
MyArray [1] = 42
MyArray [2] = new Date (2000, 1, 1)
/ / displays the length of the array 3
Window.alert (myArray.length)
/ / add some expando attributes
MyArray.expando = "Jscript!"
MyArray ["another Expando"] = "Windows"
/ / 3 is still displayed because of the two expando properties
/ / does not affect the length.
Window.alert (myArray.length)
Although Jscript does not directly support multidimensional arrays, you can store any kind of data (including other arrays) in array elements. So you can get the properties of a multi-dimensional array by storing other arrays in the elements of another array. For example, the following code creates a multiplication table for numbers up to 5:
/ / if it is a larger table, please change the number.
Var iMaxNum = 5
/ / Loop count
Var i, j
/ / New array. Because the array starts counting from 0
/ / instead of 1, so the array size is iMaxNum + 1.
Var MultiplicationTable = new Array (iMaxNum + 1)
/ / cycle for each major number (each row in the table)
For (I = 1; 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.