Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
isArray: function( obj ){
return Object.prototype.toString.call( obj ) === '[object Array]';
}
isArray: function(value)
{
var __object__ = Object.prototype;
return value && typeof(value) === 'object' && value instanceof Array && !__object__.propertyIsEnumerable.call(value, 'length') && __object__.hasOwnProperty.call(value, 'length');
};
var object = {
};
console.log(object.length) // undefined
object.constructor.prototype.length = 1;
console.log(object.length) // true
delete object.length; // false
console.log(object.length) // 1
var array = function() {
};
array.prototype.constructor = Array;
var object = new array;
console.log(object.constructor); // Array
console.log(object.length); // undefuned
var array_like = {
0: 1,
1: 2,
length: 2
};
console.log(array_like.constructor); // Object
console.log(Math.max.apply(null, array_like)); // 2
void function() {
console.log(Math.max.apply(null, arguments)); // -Infinity
}();
var not_array_like = {
length: 2
};
console.log(Math.max.apply(null, not_array_like)); // NaN
var isArray = function (object) {
return Object.prototype.toString.call( object ) === '[object Array]';
};
isArray: function(value) {
var __object__ = Object.prototype;
return value && typeof(value) === 'object' && value instanceof Array && !__object__.propertyIsEnumerable.call(value, 'length') && __object__.hasOwnProperty.call(value, 'length');
};
Дифференцирование Object, Array, Number и String