globalThis.globalThis globalThis.Object globalThis.Symbol Symbol.iterator
currently are writable: true
Can we making writable: false to make sure these object always exist?
globalThis.globalThis globalThis.Object globalThis.Symbol Symbol.iterator
currently are writable: true
Can we making writable: false to make sure these object always exist?
Symbol.iterator is writable false and configurable false, like every well-known Symbol, but like every global, Symbol is writable.
It would break a great Many use cases, including polyfilling, to make these things “undeniable”. The solution, as always with all JavaScript code, is to run your code first, and either lock down, or cache your own copy, the globals you’re concerned with. Note that altering the globals may break code.
May other use some trick such as 'use strict', once this happened, the globalThis.Symbol are writable: false, by doing this, the javascript compiler can optimize the code such as globalThis Symbol Object and so on, that's why I proposal this
Unless implementers are asking to be able to do an optimization, it’s a safe bet they don’t need to.
In general, implementations already optimize things that aren't modified, whether or not they might be modified later. This isn’t a problem that really exists, as far as i can tell.
I am thinking about implementing a Javascript VM, maybe I was at the wrong direction, any implementer can anwser my condieration?
I believe typically what is done is each builtin has a "dirty" bit for each property, that tracks whether it's been modified or not. If it has not, it uses the fast path. Hopefully implementers can weigh in and provide context.