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