Object or extend prototype #515
Unanswered
espruino-discuss
asked this question in
JavaScript
Replies: 1 comment
-
Posted at 2015-12-14 by @gfwilliams If you're writing a module? Generally I'd say:
Also doing:
Isn't great, as you've got a copy of the code in the function itself, plus a copy in the instantiated object -> prototypes can be better there too. Just to add, when minifying, anything that's exposed to the outside world (like stuff in the prototype) can't have its name changed, so uses up more memory. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2015-12-14 by Ollie
Re below snippets, can anyone advise what is least expensive from a memory perspect. I have a habit of doing the former, since I thought I had read it saved memory (or at least was quicker??) but notice that many of the modules extend prototype. So which is better, this?
or this?
Beta Was this translation helpful? Give feedback.
All reactions