Using that as a point of reference, kids born in 2005 have no recollection of the Suns in the playoffs. I was born in 1982 and my first memories of NBA basketball are from the ’87-’88 season. There is none.Ī decade of mediocrity and playoff-less basketball can create smoke screens when looking into the past. That relationship mirrors my personal relationship with Scarlett Johansson. No, there are no performance implications.The Suns and the NBA playoffs have had a complicated relationship as of late. You could do the same thing with other built-in collection types such as map.clear() or set.clear() or even any custom object/class that has methods for reducing its memory usage. Remember, that const prevents assignment to that variable name, but does not prevent mutating the contents that the variable points to.
![you dont know js kyle thompson you dont know js kyle thompson](https://petapixel.com/assets/uploads/2013/12/thompson6.jpg)
You can still massively reduce the size of that data by simply clearing the array which potentially makes the large number of objects that was in the array eligible for garbage collection if nothing else had a reference to them: bigData.length = 0 For example, if you had a really large 100,000 element array of objects (that you perhaps received from some external http call) in a const array: const bigData = I should add the even some const data can still be reduced in size and make the majority of its contents available for garbage collection. In general, you SHOULD use const as much as practical.
![you dont know js kyle thompson you dont know js kyle thompson](https://www.rollingstone.com/wp-content/uploads/2018/09/kenan-whats-up-with-that.jpg)
These are all good things when used in an appropriate case.
YOU DONT KNOW JS KYLE THOMPSON CODE
And, it prevents rogue or accidental code from ever changing the contents of that variable. It allows the developer to state some intent that the contents this variable points to are not to be changed by code and may allow the runtime to make some optimizations because it knows the contents of the variable cannot be changed. When it goes out of scope and is no longer reachable, its contents will be eligible for garbage collection.Ĭonst has a number of advantages. The garbage collector itself doesn’t treat a const variable or the contents it points to any different than a var or let variable. If you ever want to change the contents of the variable for any reason in the future, then don’t declare it as const. But, it’s just one of millions of reasons. Yes, manually enabling garbage collection on a large data structure that might be caught in a lasting scope/closure is one reason that you might want to change the variable in the future. If you want to be able to clear the contents of a variable, then that means you want to modify the variable so duh, don’t use const. This should be completely obvious to anyone who understand what const is for.Ĭalling out garbage collection as a special case for when not to use const just seems silly to me. If you want to be able to change what the variable contains at any time in the future (for any reason), then don’t use const. This is the same as any other reason for using or not using const. So, if you would like to be able to change the contents of the variable in the future for any reason (including to manually remove a reference to something to allow something to be garbage collected sooner), then don’t use const. Automatic garbage collection is not affected at all by whether it is declared const or not.
![you dont know js kyle thompson you dont know js kyle thompson](https://media.gq.com/photos/5ede9ca411eb4439b1a9eaf7/master/pass/BLMShirts.jpg)
That’s really the only difference in regard to memory management. With a const variable declaration, you can’t assign to the variable something little like "" or null to clear its contents. That note sounds a bit more of a warning than is necessary (perhaps even a bit silly) and tries to make some sort of special case out of this situation. That may be desirable, but be careful if it’s not your intent! Scope goes away, as the reference to the value can never be unset.
![you dont know js kyle thompson you dont know js kyle thompson](https://library.sportingnews.com/2021-08/klay-thompson_3xz4j02munvp1r8l733ffi2sq.jpg)
Will not be able to be garbage collected until that constant’s lexical WARNING Assigning an object or array as a constant means that value