I. Functions
Definition:
Function Square (x) {return x * x}
Ii. object,Set of named Data
1. Create
VaR o = new object (); var now = new date (); var pattern = new Regexp ("\ sjava \ s", "I ");
2. Call attributes
VaR poit = new object (); point. x = 2.3; point. Y =-1.2;
3. object initialization. The object direct quantity is composed of a list, which is an attribute/value pair separated by colons.
VaR point = {X: 2.3, Y:-1.2 };
4. Objects can also be nested
VaR rectangle = {upperleft: {X: 2, Y: 2}; lowerright: {X: 2, Y: 4 }}
5. the attribute value in the object does not need to be a constant, but can be any expression. The attribute name can be a string rather than an identifier.
3. Array
1. Arrays can store any JS data type.
Document. Images [1]. Width
2. Create an array using the constructor array ()
VaR A = new array (); A [0] = 1.2; A [1] = "bingzong"; A [2] = true; A [3] = {X: 1, Y: 3} // create an array var A = new array (1.2, "Mr. sao ", true); // only one parameter is passed. The specified parameter is the array length var A = new array (10 ); // You can also use the syntax var A = [1.2, "mr. Sao", true] // You can also store undefined elements var A = [1, 5]