2022年1月28日
摘要:
function User(name){ this.name=name; } function createByObject(obj,...args){ const constructor= Object.getPrototypeOf(obj).constructor; return new con
阅读全文
posted @ 2022-01-28 14:25
weakup
阅读(35)
推荐(0)
摘要:
function User(name){ this.name=name; } //对应左边的 // 此方法是挂上show // User.prototype.show=function(){ // console.log(this.name); // } //对应右边的 //此方法是是重新创建了一个
阅读全文
posted @ 2022-01-28 14:12
weakup
阅读(34)
推荐(0)
摘要:
let hd={name:"hd"}; let parent={ name:"parent", show(){ console.log("parent method:"+this.name) } } Object.setPrototypeOf(hd,parent); hd.show(); paren
阅读全文
posted @ 2022-01-28 13:59
weakup
阅读(25)
推荐(0)
2022年1月27日
摘要:
function User(){} User.__proto__.view=function(){ console.log("user function"); } User.prototype.show=function(){ console.log("后盾人"); } user.view(); c
阅读全文
posted @ 2022-01-27 13:59
weakup
阅读(32)
推荐(0)
2022年1月25日
摘要:
let hs={ show(){ console.log("first"); }, render(){ console.log("render"); } }; console.log(hs); // Object.prototype.show=function(){ // console.log("
阅读全文
posted @ 2022-01-25 23:27
weakup
阅读(41)
推荐(0)
2022年1月24日
摘要:
let xj={name:"xiangjun"}; console.log(xj); console.log(xj.hasOwnProperty("name")); //完全数据字典对象 let hd2=Object.create(null,{ name:{value:"houdunren"} })
阅读全文
posted @ 2022-01-24 22:53
weakup
阅读(31)
推荐(0)
2022年1月23日
摘要:
function factorial(num){ debugger return num==1?1:num*factorial(num-1); } let proxy=new Proxy(factorial,{ apply(func,obj,args){ debugger console.time(
阅读全文
posted @ 2022-01-23 18:00
weakup
阅读(334)
推荐(0)
摘要:
const user={ // name:"hundsun", // age:16 data:{name:"yss",age:12}, //访问器批量设置属性 set site(value){ [this.name,this.age] =value.split(","); }, get site()
阅读全文
posted @ 2022-01-23 14:57
weakup
阅读(27)
推荐(0)
摘要:
const user={ // name:"hundsun", // age:16 data:{name:"yss",age:12}, list:[ {price:12}, {price:12}, {price:13} ], //访问其伪造属性操作 get total(){ return this.
阅读全文
posted @ 2022-01-23 14:49
weakup
阅读(23)
推荐(0)
摘要:
const user={ // name:"hundsun", // age:16 data:{name:"yss",age:12}, set age(value){ //使用访问其保护数据 if(typeof value !=='number'){ throw new Error("error")
阅读全文
posted @ 2022-01-23 14:37
weakup
阅读(24)
推荐(0)