Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the properties of Global object and window object in Javascript

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, I would like to share with you the relevant knowledge points of Global object and window object properties in Javascript. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.

The Global object also contains some properties, some of which have been described earlier in this book. For example, the special values undefined, NaN, and Infinity are all properties of the Global object. In addition, constructors of all native reference types, such as Object and Function, are also properties of the Global object. The following table lists all the properties of the Global object.

Attribute description

Undefined Special value undefined

Date constructor Date

Nan Special value NaN

RegExp constructor RegExp

Infinity Special value Infinity

Error constructor Error

Object constructor Object

EvalError constructor EvalError

Array constructor Array

RangeError constructor RangeError

Function constructor Function

ReferenceError Construction letter ReferenceError

Boolean constructor Boolean

SyntaxError constructor SyntaxError

String constructor String

TypeError constructor TypeError

Number constructor Number

URIError constructor URIError

Window object

Although ECMAScript did not point out how to access the Global object directly, the technical staff of Nanchang Network Company suggested that Web browsers implement this global object as part of the Window object. Therefore, all variables and functions declared in the global scope become properties of the window object. Take a look at the following example:

Var color= "red"

Function sayColor () {

Alert (window.color)

}

Window.sayColor (); / / "red"

A global variable named color and a global function named sayColor () are defined. Inside sayColor (), we access the color variable through window.color to show that the global variable is a property of the window object. Then, you use window.sayColor () to call this function directly through the window object, and the result is displayed in the warning box.

That's all of the article "what are the properties of Global objects and window objects in Javascript?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report