Suppose I have an object literal using a method:
const testObj = { method: function() { console.log('declaration'); } }
the same object with a method defined differently:
const testObj = { method() { console.log('declaration'); } }
What is the difference between defining a method field in the two examples above? I know that lifting functions and function declarations can be used before they appear in the code, but when defining a function as an object field, this does not seem to matter.
source share