Js here some points in common knowledge out about the inquiries for the future
This is the first chapter, you talk about the Array.
The difference is that with the java that exist in the real js-type Array.
It can be var aValues = new Array (20); the definition of Array
Array can also be defined so
var aValues = new Array ();
aValues [0] = "aaa";
aValues [1] = "bbb";
aValues [2] = "ccc";
This definition can also
var aValues = new Array ( "aaa", "bbb", "ccc");
js array in java similar to the ArrayList, an array for each additional item, the length of the array on the dynamic growth.
For example:
var aValue = new Array ( "aaa", "bbb", "ccc");
aValues [3] = "dddd";
alert (aValues.length);
A result, did not appear in java as a null pointer, but it is 4.
If this is the location in the array 30 to place a value on how results will be?
var aValue = new Array ( "aaa", "bbb", "ccc");
aValues [30] = "dddd";
alert (aValues.length);
Correct answers, the result is 31
Then 3, to 29 the value of the location of what it will be? Yes, it's null.
Array objects have a lot of very useful methods, many of them are not of java. (Java also when such an approach can ah!).
1.toString, valueOf
It features two methods are the same as a return, in order to split the string at
var aValues = [ "a", "b", "c"];
alert (aValues.toString ());// to return to the a, b, c
2.join (separator )----------------- to the specified character as a separator at partition would be converted to string array, when a comma seperator, its role and toString ( ) the same.
var aValues = [ "a", "b", "c"];
alert (aValues.join ("-"));// to return to the abc
alert (aValues.join ("]["));// return is a] [b] [-c
3.concact (item1, item2 ,....)----------- the method parameter list is not to connect to the original array in the parameter list but added to the back of the array to form a new and return to the array,
And the original array will not be affected.
Such as: var aValues = [ "a", "b", "c"];
var aNewValues = aValues.concact ( "d", "e");
alert (aNewValues.toString); / / output is a, b, c, d, e
alert (aValues.toString); / / output so that a, b, c
Will be able to see the name of 4.objArray.pop ()--------- guess this is the operation stack. Congratulations, you guessed it, the way is to pop the last element of the array.
pop method returns the last element of an array of values, and reduce the length attribute 1, that is, to return immediately after the loss of the last element.
Combination of the following push his way to the array to use as a stack possible.
var aValues = [ "a", "b", "c"];
alert (aValues.pop ());// output is c
alert (aValues.length); / / output is 2
5. Push ([value1 [, value2 [,....]]])------------- or the operation of the stack will be added to the array parameter at the end. Such as: [1,2,3, 4]. Push ( "a", "b") will be [1,2,3,4, "a", "b"]
The difference between this and concact is concact does not affect the original array and push in the original array is in operation.
var aValues = [ "a", "b", "c"];
aValues.push ( "d", "e");
alert (aValues.toString ());// output is a, b, c, d, e
alert (aValues.length); / / output 5
6.reverse () is an interesting method to the array in reverse order of elements.
var aValues = [ "a", "b", "c"];
aValues.reverse ();
alert (aValues.toString ());// output is c, b, a
Continuing the unfinished ...
To Be Continue!!!







