对象字面量与构造对象的this
原创
坚持学前端
博主文章分类:笔记
©著作权
文章标签
js
文章分类
运维
©著作权归作者所有:来自51CTO博客作者坚持学前端的原创作品,请联系作者获取转载授权,否则将追究法律责任
v
ar data = {
msg: "外部",
};
var b = "123";
let obj1 = {
a: function () {
console.log(this);
console.log(this.b);
},
b: 1,
c: () => {
console.log(this);
console.log(this.b);
},
};
obj1.a();
obj1.c();
var q = 123;
function Vue() {
var q = 54;
this.log = function () {
console.log(arguments);
};
this.data = {
msg: "hello world",
};
this.print = function () {
var q = 43;
console.log(this.data.msg, q);
};
this.print1 = () => {
console.log(this.data.msg, q);
};
}
console.log(q, "q", 121, 12, 1, 21, 2, 1);
console.log(console);
let obj = new Vue();
obj.log(q, "q", 121, 12, 1, 21, 2, 1);
obj.print();
obj.print1();