How does es6 handle memory in classes? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

5th Jan 2019, 2:36 PM
Cameron Hansen
Cameron Hansen - avatar
4 Answers
+ 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#.
6th Jan 2019, 7:23 AM
David Carroll
David Carroll - avatar
+ 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.
5th Jan 2019, 3:40 PM
Calviղ
Calviղ - avatar
+ 2
Hey, that's a neat trick! I will definately use that. Thank's Paul
5th Jan 2019, 2:52 PM
Cameron Hansen
Cameron Hansen - avatar
+ 1
Thanks David!
8th Jan 2019, 11:38 PM
Cameron Hansen
Cameron Hansen - avatar