thisの確認 3
this - まとめ その3- モジュールパターン
by s_hiroshi
JavaScript
const o = (function() {
let name = 'foo';
function showName() {
console.log(name); // foo
console.log(this.name); // foo object
}
function showThis() {
console.log(this); // Object
}
return {
name: 'foo object',
showName: showName,
showThis: showThis
};
}());
o.showName();
o.showThis();