前端-注意
前端注意事项:
响应式布局
@media属性
this到底谁?
name = 'alex' function func(){ console.log(this.name); # window.name } func()
var name = 'alex'; function func() { var name = 'mjj'; function inner() { console.log(this.name); // window “alex” } inner() }
var name = 'alex'; function func() { var name = 'mjj'; (function(){ console.log(this.name); // window “alex” 自执行函数 })(); } func();
var name = 'alex'; var v = { name:'mjj', func:function () { console.log(this.name); # “mjj” } }; v.func()
var name = 'alex'; var v = { name:'mjj', func:function () { console.log(this.name); // mjj (function () { console.log(this.name); // alex window.name 自执行函数指的是window
})() } }; v.func()
var name = 'alex'; var v = { name:'mjj', func:function () { console.log(this.name); // mjj var that = this; (function () { console.log(that.name); // mjj })() } }; v.func()