js array-like object

 

The arguments object cannot be created explicitly, the arguments object is only available at the beginning of the function. The arguments object of a function is not an array, and individual arguments are accessed in the same way as array elements . The index n is actually one of the arguments of the 0…n properties of the arguments object.

 

example

 

var obj = {
	0 : "first",
	1 : "second",
	2 : "third",
	length : 3,
	splice : function ( index ) {
		delete this[index];
	}
};

console.dir(obj);
console.log('obj instanceof Array is not an array', obj instanceof Array );

var myArray = ["first","second","third"];
console.dir(myArray );
console.log('myArray instanceof Array是数组', myArray instanceof Array );

 

 

 

jQuery.makeArray(obj) provided by the jquery plugin

 

Converts an array-like object to an array object .

 

Array-like objects have a length property whose members are indexed from 0 to length - 1. In practice this function will be used automatically in jQuery without special conversion. 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326776586&siteId=291194637