global objects
全局对象
一个全局对象
的是全局对象
In Node modules, this at the top level doesn't reference the global object . Unlike other global objects , Math is not a constructor. In sloppy mode, it will be the global object . For instance, here we use it as a global object . In both cases the entire person is meant. Combinations with other parts of speech
因此,要访问全局对象 ,你需要在不同的JavaScript环境中使用不同的语法。 As a result, to access the global object , you need to use different syntax in different JavaScript environments. 另一种在浏览器环境中访问全局对象 的方法是使用frames属性,该属性的作用类似于self和window:. Another way to access the global object in the browser environment is to use the frames property, which works similar to self and window. Node提供以下几个全局对象 ,它们是所有模块都可以调用的。 Node provides the following global objects , which are called by all modules. 在全局上下文中,this就等于全局对象 本身(这意味着,这里的this等于变量对象):. In the global context, a this value is the global object itself(that means, this value here equals to variable object): . 全局对象 可以携带时间同步、报警、队列及其它信息,并且还与RTOS内核共享HMI等Windows资源。Global objects can carry time synchronization, alarms, queues, and other information, and also share Windows resources like HMIs with RTOS cores. 可见副作用的例子包括修改全局对象 或通过引用传递的参数。 Examples of observable side effects include modifying a global object or a parameter passed by reference. 但是有一些全局对象 并不是,且其属性和方法都是静态的。 However, some global objects are not and their properties and methods are static. 如果你需要在没有硬编码的window标识符下访问全局对象 ,你可以在任何层级的函数作用域中做如下操作:. If you need to access the global object without hard-coding the identifier window, you can do the following from any level of nested function scope. 在Webkit里,DOM全局对象 会负责存储window里的变量状态。 In WebKit, DOM global objects are in charge of storing the variable state of a window. 这些引用全局对象 的不同方式使编写能够在多个环境中工作的可移植JavaScript代码变得非常困难。 These different ways of referencing the global object have made it tough to write a portable JavaScript code that works in multiple environments. 使用任何函数外部的var初始化的变量将分配给全局对象 ,具有全局作用域并且是任何地方可见。 A variable initialized with var outside of any function is assigned to the global object , has a global scope and is visible everywhere. The global object is not a property of any other object, so it does not have a name. 这里只有一类函数除外,那就是通过Function构造器创建的函数,因为其[[Scope]]只包含全局对象 。 An exception to this rule can be functions created via Function constructor which[[Scope]] contains only global object . 所以,回到全局上下文的变量对象-这里变量对象是全局对象 自身:. So, coming back to variable object of the global context- here variable object is the global object itself. There are a number of situations that could cause this to be bound to the global object . 在浏览器中,方便起见,该全局对象 有个附加属性叫做window,此window(通常)指向该全局对象 本身。 In browsers, for convenience, there is an additional property of the global object called window that(usually) points to the global object itself. 在上面的第一个例子中,在函数调用返回之后,2个对象不再被从全局对象 可达的东西引用。 In the first above example, after the function call returns, the 2 objects are not referenced anymore by something reachable from the global object . 在顶级JavaScript代码中(即,不包含在任何函数定义中的代码),范围链由单个对象即全局对象 组成。 In top-level JavaScript code(i.e., code not contained within any function definitions), the scope chain consists of a single object, the global object . 在引入globalThis之前,一种常用的跨环境访问全局对象 的方法是使用以下模式:. Prior to the introduction of globalThis, a common way to access the global object across different environments was to use the following pattern. 问题就在于当函数通过Function构造器来创建的时候,其[[Scope]]属性永远都只包含全局对象 。 And the matter is that[[Scope]] property of functions created via the Function constructor contains always only the global object . 那么,回到全局上下文中的变量对象上--这里的变量对象就是全局对象 本身。 So, coming back to variable object of the global context- here variable object is the global object itself. 相反,当getFullname()被指定为test的变量,那个语境指向全局对象 (window)。 On the contrary, when getFullname() is assigned to the test variable, the context refers to the global object (window). 例如,当JavaScript代码引用parseInt()函数时,它引用的是全局对象 的parseInt属性。 When JavaScript code refers to the parseInt() function, for example, it is referring to the parseInt property of the global object . 这里我们再次回到上面描述的例子,this设置为全局对象 。 Here again we come back to the described above case, and again, this value is set to global object .
Display more examples
Results: 29 ,
Time: 0.0173