Objects in ECMAScript are actually a collection of data and functions.
Object is the basis of all objects in ECMAScript.
Understanding: The Object type is the basis of all its instances. In other words, any properties and methods that the Object type has also exist in more specific objects.
All instances of Object have the following properties and methods
1.Constructor: Saves the function used to create the current object
2.hasOwnProperty(propertyName): used to check whether the given property exists in the current object instance (not in the prototype). The attribute name as the parameter must be specified as a string
3. isPrototypeOf(object): used to check whether the incoming object is a prototype of another object
4. toLocalString(): Returns the string representation of the object, which corresponds to the execution environment.
5.toString(): Returns the string representation of the object
6.valueOf(): Returns the object's string, number or boolean representation. Usually the return value of the toString() method is the same
Global Object
Global objects have important uses in JavaScript: The properties of a global object are symbols defined globally. JavaScript programs can be used directly. When the interpreter is started, it will create a new global object and give it a set of defined initial properties:
Global properties, such as undefined, Infinity
Global functions, such as parseInt()
Constructors, such as Data(),
Global objects, such as Math and JSON
Packaging object
See an example like this:
var s = "hello world!";var word = s.substring(s.indexOf(" ")+1, s.length);Since a string is not an object, why does it have properties? As long as the attribute of string s is referenced, JavaScript will convert the string value into an object by calling new String(s).
Like strings, numbers and boolean values also have corresponding methods. Other similar packaging classes:
Number objectString objectBoolean ObjectFunction ObjectRegExp ObjectErrorSyntaxErrorReferenceErrorTypeError…Immutable original values and mutable original object references
The original value is unchangeable, and the comparison of the original value is a value comparison, and the comparison of objects is not a value comparison: even if two objects contain the same attributes and the same value, they are not equal. We usually call objects reference types, the values of objects are referenced, and the comparison of objects is also referenced, and they are equal if and only if they refer to the same basis exclusively;