Yes, we can assign key-value pairs obj.key=val, and we get value back when return obj[key]. Using Map is also sensible too. ;)
We just need to be aware that when assigning keys with dot notation, and if we are passing the key through variable, the variable name will be actually assigned as the key(variable won't be recognized).
I'm going to update the article to include this thought! Thank you for your ideas! :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I've always found that kind of implementation overkill. Until required.
Would hurt to create an
obj={}
assign valuesobj.key=val
andreturn obj[key]
?Or
obj = new Map();
set/get et al?Thanks for your comment!
Yes, we can assign key-value pairs
obj.key=val
, and we get value back whenreturn obj[key]
. Using Map is also sensible too. ;)We just need to be aware that when assigning keys with dot notation, and if we are passing the key through variable, the variable name will be actually assigned as the key(variable won't be recognized).
I'm going to update the article to include this thought! Thank you for your ideas! :)