Output: arrow function vs regular function as object literal methods, both logging this.name
EasyP1Output
What does this code print?
1const obj = {2 label: 'obj',3 regular: function () {4 return this.label;5 },6 arrow: () => this.label,7};8console.log(obj.regular());9console.log(obj.arrow());
Saved automatically
One line per console.log. Arrays as [1, 2, 3], objects as { a: 1 }, an uncaught error as Uncaught TypeError: message (Chrome and Node wording).
Hints
Saved automatically