// これまでの関数 var printName = function() { document.write(this + "<br>"); document.write(this.myName + "<br>"); }; var human = { myName: "yuu", print: printName } human.print(); // アロー関数 var printNameArrow = () => { document.write(this + "<br>"); document.write(this.myName + "<br>"); }; var humanArrow = { myName: "mamoru", print: printNameArrow } humanArrow.print();
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter