Message from JavaScript discussions

October 2018

— Node doesn't do this

— 

> function Meme() {
... return { foo: 'bar' }
... }
undefined
> m = new Meme()
{ foo: 'bar' }
> m instanceof Meme
false

> function Memery() {
... this.foo = 'bar';
... }
undefined
> m = new Memery()
Memery { foo: 'bar' }
> m instanceof Memery
true
>

— Wat do u mean?

— No

— Instance methods are bad practice

— Use prototype methods

— Why is that bad?

— Because you're creating functions per instance

— Not per class

— 

new InstanceClass();
// methods created on every instance
new PrototypeClass();
// methods created once, when the class was defined

Message permanent page

— No, im not creating functions, im talking about assignment. if the function closed in upper scope, it wont be "created".

Message permanent page

— Right, you'll just have the cost of a reference per object per function