DEV Community

Discussion on: How to make CRUD operations in JSON

Collapse
 
diegonvs profile image
Diego Nascimento • Edited

Hey Camilo, instead of using delete, you could set the pointer to null. #perfTip :p

Collapse
 
equiman profile image
Camilo Martinez

Sorry I'm lost, could you please write the example code?

Collapse
 
diegonvs profile image
Diego Nascimento

On delete operation you can use got[character] = null; instead of delete got[character];. Take a look on jsperf.com/delete-vs-undefined-vs-...

Thread Thread
 
equiman profile image
Camilo Martinez • Edited

Not works as CRU*D* operation, because the 'character' is not removed, just the values are replaced by null.

I tested changing on Delete script. When run the script show: Tyrion: null.

Can be used if you want leave the character, but remove his data.

Nice link BTW. I did not know about the performance comparison between null and delete

Some comments have been hidden by the post's author - find out more