Objects in JavaScript

Source: Internet
Author: User

Knowledge Content:

1.JavaScript objects

Classification of 2.JavaScript objects

3. Accessing the properties and methods of an object

One, JavaScript objects

1. What is a JavaScript object

JavaScript objects:

    • JavaScript objects can be said to be one of the basic JavaScript data types, but composite types
    • Almost everything in JavaScript is an object
    • JavaScript objects are data that owns properties and methods

2. How to understand JavaScript objects

JavaScript objects can be simply understood as key-value pairs (name:value) in the form of:

    • JavaScript objects like dictionaries in Python, associative arrays in PHP, and other data types
    • Name can be either a variable name or a function name
    • Values (value) can be any data type (including, of course, objects)

Ii. Classification of JavaScript objects

Objects in 1.JavaScript are divided into two categories: custom objects and built-in objects

Custom objects are defined by ourselves, and the built-in objects are JavaScript-like embedded modules in Python

2.JavaScript Custom Objects

In a classic object-oriented language, an object is a collection of data and operations that are performed on that data. Unlike C + + and Java, JavaScript is a prototype-based programming language that does not have a class statement, but instead uses the function as a class

(1) The custom object is created as follows:

(2) Create an object instance:

1 //The second of the above:2 varperson =Object ()3Person.name = "wyb"4Person.age = 215 6 7 //object Literal method:8 varperson = {9Name: "XASDF",TenAge:21 One } A //Note: Property names here can be used as strings or without strings, and property names without strings are automatically converted to strings

(3) Note that attribute names can be placed between quotation marks or written directly between quotation marks, and must be quoted when the property name has the following conditions:

3.JavaScript Built-in objects

JavaScript built-in objects are: Date, REGEXP, Error, array objects (arrays), object, Function, math, and so on, which will be introduced at the end

Iii. accessing objects ' properties and methods

1. Properties in an Object

2. Three related object characteristics

3. Property manipulation

4. Access Methods

Iv. JavaScript built-in objects

Objects in JavaScript

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.