How can I add an object property to the global object in rhino javascript

后端 未结 5 1873
迷失自我
迷失自我 2021-02-15 18:48

I have some properties in an object that I would like to add to the global namespace. In javascript on the browser I could just add it to the window object like so:

5条回答
  •  不知归路
    2021-02-15 18:56

    You could just define your own window object as a top-level variable:

    var window = {};
    

    You can then assign values to it as you please. ("window" probably isn't the best variable name in this situation, though.)

    See also: Can I create a 'window' object for javascript running in the Java6 Rhino Script Engine

提交回复
热议问题