Skip to main content

Command Palette

Search for a command to run...

JavaScript functions or methods?

Updated
1 min readView as Markdown

ECMAScript standards are evolving rapidly with lots of new features being added regularly. Sometimes there are new features (like inclusion of class keyword) and sometimes they add to existing features.

Recently JS got the ability to define "methods" inside object literals which is an alternate to "function" property of object literals.

Which one is better from the point of view of memory utilisation?

image.png

G

printThis(), since it is a 'mere' method, while printThat() is a function and comes with the 'weight' of its own prototype.

M
Manjunath5y ago

printThis :)