fullName : function() { return this.firstName + " " + this.lastName ; }
function myFunction() { return this; }
<button onclick = "this.style.display = 'none' "> 点击删除; </button>
var person = { firstName : "Mirror", lastName : "China", id : 10086, fullName : function() { return this.firstName + " " + this.lastName ; } };
this.firstName 意味着 this person 对象中的 firstName和lastName属性
var person1 = { fullName : function() { return this.firstName + " " + this.lastName ; } }; var person2 = { firstName : "Mirror" , lastName : "China" , }; person1.fullName.call(person2) ; // person2将会作为参数供person1调用
本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。
我来说两句