var myObject = {\"myKey\" : \"myValue\"}
typeof(myObject.myKey) returns `string`
myObject.myKey = \"newValue\"
console.log(myObject.myKey) prints newValue
Browser-supplied host objects behave in ways that are not constrained by the semantics of the language. That is, document
looks like a JavaScript object, but it's not. It's part of the runtime environment.
The JavaScript spec is written in terms of various internal "method" descriptions. Host objects like window
and document
have special versions of those internal methods. Thus, the runtime follows the spec as to how the =
assignment process works, but the internal method [[Put]]
is simply special.