Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pros and Cons of "dictionary mode"

It is to my knowledge that with Javascript when you delete an entry on a object, at least with chrome it puts the object into "dictionary mode" or "slow mode"

Example:

var user = { name: 'connor', sex: 'male' }; 
// user is in "fast mode"

delete user.sex;
// user is in ("slow" or "dictionary") mode 

When can this be beneficial and when can it be detrimental?

A specific case to go by would be, I have an object and when the application starts the object is empty, but as the code is run and the application memory builds up it can potentially become very large and the object will never decrease in size until the application closes by which it will not exist.

Also is there any semantics around this mode?

like image 975
iConnor Avatar asked May 04 '14 11:05

iConnor


1 Answers

this article has some answers about how google's v8 handles object properties

the article confirms that there are such things as slow and fast properties

my guess is that if your property names change frequently the "Map" is a better way to go.

https://v8.dev/blog/fast-properties

like image 114
Martijn Scheffer Avatar answered Oct 24 '22 12:10

Martijn Scheffer