# Make global object's properly to writable:false,

**URL:** <https://es.discourse.group/t/make-global-objects-properly-to-writable-false/649>\
**Category:** 💡 Ideas\
**Created:** [February 20, 2021, 7:33am UTC](https://es.discourse.group/t/make-global-objects-properly-to-writable-false/649 "2021-02-20T07:33:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lygstate](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/lygstate/32/628_2.png) [@lygstate](https://es.discourse.group/u/lygstate)\
**Post date:** [February 20, 2021, 7:33am UTC](https://es.discourse.group/t/make-global-objects-properly-to-writable-false/649/1 "2021-02-20T07:33:36Z")

</div>

globalThis.globalThis globalThis.Object globalThis.Symbol Symbol.iterator  
currently are writable: true

Can we making writable: false to make sure these object always exist?

---

<div class="post-metadata">

**Author:** ![ljharb](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ljharb/32/8_2.png) [@ljharb](https://es.discourse.group/u/ljharb)\
**Post date:** [February 21, 2021, 4:27pm UTC](https://es.discourse.group/t/make-global-objects-properly-to-writable-false/649/2 "2021-02-21T16:27:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lygstate](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/lygstate/32/628_2.png) [@lygstate](https://es.discourse.group/u/lygstate)\
**Post date:** [February 22, 2021, 5:08am UTC](https://es.discourse.group/t/make-global-objects-properly-to-writable-false/649/3 "2021-02-22T05:08:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ljharb](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ljharb/32/8_2.png) [@ljharb](https://es.discourse.group/u/ljharb)\
**Post date:** [February 22, 2021, 3:26pm UTC](https://es.discourse.group/t/make-global-objects-properly-to-writable-false/649/4 "2021-02-22T15:26:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lygstate](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/lygstate/32/628_2.png) [@lygstate](https://es.discourse.group/u/lygstate)\
**Post date:** [February 22, 2021, 3:43pm UTC](https://es.discourse.group/t/make-global-objects-properly-to-writable-false/649/5 "2021-02-22T15:43:56Z")

</div>

I am thinking about implementing a Javascript VM, maybe I was at the wrong direction, any implementer can anwser my condieration?

---

<div class="post-metadata">

**Author:** ![ljharb](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ljharb/32/8_2.png) [@ljharb](https://es.discourse.group/u/ljharb)\
**Post date:** [February 22, 2021, 5:18pm UTC](https://es.discourse.group/t/make-global-objects-properly-to-writable-false/649/6 "2021-02-22T17:18:41Z")

</div>

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.
