+ 2
How does es6 handle memory in classes?
How does memory work in es6? Specifically with their classes and how class members are handled. I am comming from a C # and C++ background(mostly C#). For example if you change a class member value outside a c# class, it acts like a refrence, and the member value recieves that change. This does not apply for c# structs. I am new to the javascript world. T.I.A
4 odpowiedzi
+ 6
There are quite a few differences between classes in C# and Javascript.
For starters, Javascript doesn't really implement classes in the traditional sense as C# and C++.
What appears to be classes in ES6 are just syntactic sugar for what is actually Javascript's prototypal inheritance.
Checkout the following links to get a better understanding of this in Javascript.
https://hacks.mozilla.org/2015/07/es6-in-depth-classes/
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
Hopefully this will help setup the proper context as you continue researching how Javascript is different from C#.
+ 5
JavaScript automatic allocates memory when objects are created and frees it when they are not used anymore
We also could release an object from memory by setting it null.
obj = null; //It would be garbage collected.
+ 2
Hey, that's a neat trick! I will definately use that. Thank's Paul
+ 1
Thanks David!