- 博客(5)
- 收藏
- 关注
原创 原型链继承:
function Animal() {this.name = ‘cat’this.msg = {age: 9}}Animal.prototype.greet = function () {console.log(‘hehe’)}function Dog() {this.name = ‘dog’}Dog.prototype = new Animal() //核心一步const a = new Dog()a.msg.age = ‘99’const b = new Animal()
2020-09-12 20:55:42
44
原创 call ,apply, bind
const obj = {x: 10}function fn() {console.log(this)}fn.call(obj) //objfn.apply(obj) //objfn.bind(obj)() //objconst obj = {x: 10}function fn() {console.log(this)}fn.call(obj) //objfn.apply(obj) //objfn.bind(obj)() //objconst obj
2020-09-12 20:55:12
43
原创 f执行时候的[[scope]]属性:
[AO:{arguments:[],this:window},AO:{scope:“local scope”,f:function},global:{scope :“local scope”,checkscope:function}]根据先后顺序scope变量输出为"local scope"[AO:{arguments:[],this:window},AO:{scope:“local scope”,f:function},global:{scope :“lo
2020-09-12 20:53:44
84
原创 1经典面试题
1 + ‘1’true + 0{}+[]4 + {}4 + [1]‘a’ + + ‘b’console.log ( [] == 0 )console.log ( ! [] == 0 )console.log ( [] == ! [] )console.log ( [] == [] )console.log({} == !{})console.log({} == {})1 + ‘1’true + 0{}+[]4 + {}4 + [1]‘a’ + + ‘b’console.l
2020-09-12 20:53:13
42
原创 (所有对象转换boolean都为true)
let obj={value:‘你好啊’,num:2,toString:function(){return this.value},valueOf:function(){return this.num},}console.log(obj+‘明天’) //2明天console.log(obj+1) // 3console.log(String(obj)) // 你好啊let obj={value:‘你好啊’,num:2,toString:function(){re
2020-09-12 20:52:44
250
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人