var o = {
foo : "bar"
}
var o = new Object();
var p = Object.create(o);
var O = {
x : 1
};
function P() {
this.y = 2;
}
P.prototype = O;
var t = new P();
console.log(t);
console.log('x' in t);//true
console.log(t.hasOwnProperty('x'));//false
var o = {
foo : 'bar'
}
Object.defineProperty(o, "foo", { writable : false });
o.foo = 'world';
console.log(o.foo);//仍然输出bar
for (p in Array) {
console.log(p);
}
var book = {
_year: 2004,
edition: 1
};
Object.defineProperty(book, "year", {
get: function () {
console.log('get year');
return this._year;
},
set: function (newValue) {
console.log('set year');
if (newValue > 2004) {
this._year = newValue;
this.edition += newValue - 2004;
}
}
});
book.year = 2005;//控制台输出‘set year'
console.log(book.year);//控制台输出‘get year'和year的值
function bar(o) {
var f = function() { return "Hello World!"; }
o.__proto__ = f.__proto__;
f.__proto__ = o;
return f;
}
var o = { x: 5 };
var foo = bar(o);
console.log(foo());
console.log(foo.x);
console.log(typeof foo);//function
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有