导航
Array.prototype
function test() {
console.log(arguments);
}
test(1, 2, 3, 4);
var obj = {
0: 0,
1: 1,
2: 2,
length: 3
};
console.log(obj);
var obj = {
0: 0,
1: 1,
2: 2,
length: 3,
splice: Array.prototype.splice
};
console.log(obj);
var obj = {
'2': 3,
'3': 4,
length: 2,
'splice': Array.prototype.splice,
'push': Array.prototype.push
}
obj.push(1);
obj.push(2);
console.log(obj);
// 原理
Array.prototype.push = function(el) {
this[this.length] = el;
this.length++;
}
var obj = {
'2': 3,
'3': 4,
length: 2,
'splice': Array.prototype.splice,
'push': Array.prototype.push
}
obj.push(1);
// obj[2] = 1
obj.push(2);
// obj[3] = 2
console.log(obj);
function test() {
console.log(typeof(arguments));
}
test();
// 返回 object