4 ms·
What is the syntax used in the third example of "This in an object method"? I have never seen it, looks like an error to me.
by vesinisa 9y ago
What is the syntax used in the third example of "This in an object method"? I have never seen it, looks like an error to me.
- jholman 9y agoWhen you say "looks like an error", did you try running it? I assume you have a web browser handy. All the examples in that section both look correct to me, and run as I'd expect in the JS environment I have closest-to-hand. If you want help on the syntax, you should pose a more-specific question. Exactly what code looks like an error, and why do you think it's an error, and so on?
- vesinisa 9y agoSorry, I was on mobile and could not run it in the browser console. It was an honest question, but I already got the answer.
- abritinthebay 9y agoIt’s using object shorthand. Rather than: {foo: foo, bar: function(){}} You can just do: {foo, bar(){}}
- fenomas 9y agoIt's new syntactic sugar for declaring object literals. Google "es6 object literals".