fn.call(o); //改变函数fn的作用域对象
fn.apply(o); //改变函数fn的作用域对象
fn.bind(o); //将函数fn的作用域绑定到对象o上
fn.apply(o); //改变函数fn的作用域对象
fn.bind(o); //将函数fn的作用域绑定到对象o上
2018-04-25
定义函数的三种形式:
1,函数声明
function fn(){}
2,函数表达式
var fn = function(){};
3,函数对象
var fn = new Function('a', 'b', 'return a + b');
1,函数声明
function fn(){}
2,函数表达式
var fn = function(){};
3,函数对象
var fn = new Function('a', 'b', 'return a + b');
2018-04-25
1,a.concat();
2,a.join();
3,a.reverse();
4, a.sort();
5, a.slice();
6, a.splice();
7, a.valueOf();
8, a.toString();
9, a.indexOf();
10, a.lastInexOf();
11, a.every();
12, a.some();
13, a.filter();
14, a.map();
15, a.forEach();
2,a.join();
3,a.reverse();
4, a.sort();
5, a.slice();
6, a.splice();
7, a.valueOf();
8, a.toString();
9, a.indexOf();
10, a.lastInexOf();
11, a.every();
12, a.some();
13, a.filter();
14, a.map();
15, a.forEach();
2018-04-25
1, Object.preventExtensions(o);
2, Object.seal(o);
3, Object.freeze(o);
4, Object.isExtensible(o);
5, Object.isSealed(o);
6, Object.isFrozen(o);
2, Object.seal(o);
3, Object.freeze(o);
4, Object.isExtensible(o);
5, Object.isSealed(o);
6, Object.isFrozen(o);
2018-04-23
var person = {name: 'zhao', salary: 2000};
Object.defineProperty(person, promote, {
set: function(level){this.salary *= 1 + 0.001*level;}
});
测试:
person.promote = 10; //工作十年,升到第十级
alert(person.salary); //工资涨到2020元
Object.defineProperty(person, promote, {
set: function(level){this.salary *= 1 + 0.001*level;}
});
测试:
person.promote = 10; //工作十年,升到第十级
alert(person.salary); //工资涨到2020元
2018-04-23
1, Object.getOwnPropertyDescriptor(o1, 'name'); //取得属性的特性
2, Object.defineProperty(o1, 'name', {value: 'zhao', enumerable: true, writable: true, configurable: true}); //定义一个属性
3, Object.getOwnPropertyDescriptors(o1); //取得所有属性的特性
4, Object.defineProperties(o1, oooo); //定义多个属性
2, Object.defineProperty(o1, 'name', {value: 'zhao', enumerable: true, writable: true, configurable: true}); //定义一个属性
3, Object.getOwnPropertyDescriptors(o1); //取得所有属性的特性
4, Object.defineProperties(o1, oooo); //定义多个属性
2018-04-23
var book = {
editor: 0,
_year: 2015,
get year(){
return this._year;
}
set year(y){
if(y < this._year){
alert('Incorrect year');
}
else{
this._year = y;
this.editor = y - this._year;
}
}
}
}
}
}
}
}
}
};
editor: 0,
_year: 2015,
get year(){
return this._year;
}
set year(y){
if(y < this._year){
alert('Incorrect year');
}
else{
this._year = y;
this.editor = y - this._year;
}
}
}
}
}
}
}
}
}
};
2018-04-23