3 ms·
It’s not. The null version won’t have methods like hasOwnProperty etc. If it wasn’t clear, i was mentioning 2 ways of initializing, not that you should reassig
by sbr464 7y ago
It’s not. The null version won’t have methods like hasOwnProperty etc.
If it wasn’t clear, i was mentioning 2 ways of initializing, not that you should reassign immediately.
- sbr464 7y agoI see a lot of people accessing a map/dictionary using the “for (key in)” pattern, not realizing they are inheriting any method/prototype names along with their basic dictionary they’ve defined. Using Object.create(null) is an easy way to not only save memory, but reduce issues if using dynamic key names. https://stackoverflow.com/questions/500504/why-is-using-for-in-with-array-iteration-a-bad-idea/500531#500531 https://stackoverflow.com/questions/500504/why-is-using-for-...