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 is the javascript object?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces the relevant knowledge of "what is the javascript object?" in the operation of actual cases, many people will encounter such a dilemma, and then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Javascript has a date. JavaScript supports three kinds of objects: 1, built-in objects, which are predefined by JavaScript language itself, such as String, Number, Array, etc.; 2, browser objects; and 3, custom objects.

The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.

In JavaScript, almost everything is an object. An object is a collection of related properties and methods. JavaScript supports three kinds of objects: built-in objects, browser objects, and custom objects.

1. JavaScript built-in object:

It refers to the predefined objects in the JavaScript language, which are defined in the ECMAScript standard and are implemented by all browser manufacturers. Because of the unity of the standard, the browser compatibility of these objects is not too big.

String 、 Number 、 Boolean 、 Array 、 Date 、 RegExp 、 Math 、 Error 、 Object 、 Function 、 Global

2. JavaScript Window-browser object:

The browser object model (Browser Object Model (BOM)) allows JavaScript to talk to the browser.

There is no official standard for the browser object Model (BOM). Modern browsers have (almost) implemented the same methods and properties of JavaScript interaction, so it is often mentioned as methods and properties of BOM.

Because modern browsers have (almost) implemented the same methods and properties of JavaScript interactivity, they are often considered to be BOM methods and properties.

Window object:

All browsers support window objects. It represents the browser window.

1), the window object is the top object

2). The window object has six attributes, including document, frames, history, location, navigator and screen, which are also objects themselves.

3) the document attribute under the window object is also an object, and five attributes (anchors, forms, images, links, location) under the document are also objects.

3. JavaScript custom object:

With JavaScript, you can define and create your own objects.

There are many different ways to create new objects, two of which are described below:

Use Object to define and create an instance of the object.

Use the literal amount of the object.

1) use Object

In JavaScript, almost all objects are instances of type Object, and they inherit properties and methods from Object.prototype.

The Object constructor creates an object wrapper.

The Object constructor, which creates an object based on a given parameter, as follows:

If the given value is null or undefined, an empty object is created and returned.

If a value of a primitive type is passed in, an object of its wrapper type is constructed.

If a value of the reference type is passed in, it will still be returned, and the variables copied by them will hold the same reference address as the source object.

When called as a non-constructor, the behavior of Object is equivalent to new Object ().

Syntax format:

/ / call new Object ([value]) as a constructor

Value can be any value.

The following example uses Object to generate Boolean objects:

/ / equivalent to o = new Boolean (true); var o = new Object (true)

2) use the literal amount of object

You can also use object literals to create objects in the following syntax format:

{name1: value1, name2: value2,...nameN: valueN}

In fact, name:value pairs are created in curly braces, and then name:value pairs are separated by commas.

That's all for "what is the javascript object?" Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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