If you assign some property to a string primitive with an intention of getting the value back at some point, you will only be returned undefined because the temporary String Object was discarded then and there.
undefined
MDN: primitive values:
All types except objects define immutable values (that is, values which can't be changed).
seems like a more straightforward explanation - i.e. nothing was changed in the first place - JavaScript just ignores the attempt of mutation.
@peerreynders Indeed. Thanks for taking out time to read :)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
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.
MDN: primitive values:
seems like a more straightforward explanation - i.e. nothing was changed in the first place - JavaScript just ignores the attempt of mutation.
@peerreynders Indeed. Thanks for taking out time to read :)