GithubHelp home page GithubHelp logo

Adding globalThis about hermes HOT 6 CLOSED

facebook avatar facebook commented on April 25, 2024
Adding globalThis

from hermes.

Comments (6)

avp avatar avp commented on April 25, 2024 3

d088f6f adds this.

from hermes.

ljharb avatar ljharb commented on April 25, 2024

globalThis is the only standard JS global :-) the others are part of node or browsers.

from hermes.

avp avatar avp commented on April 25, 2024

While globalThis isn't part of the standard yet (still in Stage 3 of the TC39 proposal process), it's already gained some amount of adoption and it seems reasonable to plan to add it to Hermes. We'll work on adding the property to the global object soon.

If you need access to the global object before globalThis is added to Hermes, you can use the Function constructor (which will be a little slower but should produce the correct output):

let global = (new Function('return this'))();

from hermes.

ljharb avatar ljharb commented on April 25, 2024

@avp it's shipping in every browser https://twitter.com/mathias/status/1151140681374547969 so the stage isn't really relevant; it'll be stage 4 relatively soon. Glad to hear you're adding it :-)

from hermes.

dulinriley avatar dulinriley commented on April 25, 2024

It’s a shame that globalThis is a property that is writable, if it was a keyword we could compile it to GetGlobalObject in HBC.

from hermes.

ljharb avatar ljharb commented on April 25, 2024

@dulinriley see item 2: https://github.com/tc39/proposal-global/blob/master/NAMING.md#constraints

from hermes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.