lukeed / dset

A tiny (197B) utility for safely writing deep Object values~!
MIT License
759 stars 25 forks source link

Alternative implementation #3

Closed EmilTholin closed 6 years ago

EmilTholin commented 6 years ago

As discussed in this thread.

Should it be t[k[i]] == null ? {} : t[k[i]] instead of t[k[i]] || {} like you outlined in the thread?

EmilTholin commented 6 years ago

Awesome! Thanks.

lukeed commented 6 years ago

Obviously didn't need the variable, but at the same time, avoids accessing the array indices twice so it's a tiny performance win 😆 For 2 bytes, I'll take it.

https://github.com/lukeed/deepset/blob/master/src/index.js#L5-L6