function
function showNameFunction() {
this.name = 'wadayamada';
console.log(this);
}
showNameFunction();
Output
<ref *1> Object [global] {
global: [Circular *1],
clearInterval: [Function: clearInterval],
clearTimeout: [Function: clearTimeout],
setInterval: [Function: setInterval],
setTimeout: [Function: setTimeout] {
[Symbol(nodejs.util.promisify.custom)]: [Function (anonymous)]
},
queueMicrotask: [Function: queueMicrotask],
clearImmediate: [Function: clearImmediate],
setImmediate: [Function: setImmediate] {
[Symbol(nodejs.util.promisify.custom)]: [Function (anonymous)]
},
name: 'wadayamada'
}
アロー関数
const showNameArrowFunction = () => {
this.name = 'wadayamada';
console.log(this);
};
showNameArrowFunction();
Output
{ name: 'wadayamada' }