DEV Community

Madhuri Padegal
Madhuri Padegal

Posted on


Booleans can be objects (if defined with the new keyword)
Numbers can be objects (if defined with the new keyword)
Strings can be objects (if defined with the new keyword)
Dates are always objects
Math are always objects
Regular expressions are always objects
Arrays are always objects
Functions are always objects
Objects are always objects

OBJECT properties:
Properties are the values associated with a JavaScript object.
A JavaScript object is a collection of unordered properties.
Properties can usually be changed, added, and deleted, but some are read only.
Accessing JS objects: or ObjectName['property']
JS Objects methods:
For example we have
var person = {
 first_Name: "John",
 last_Name : "Doe",
 id : 5566,
full_name : function() {
 return this.first_Name + " " + this.last_Name;
In a function definition, this refers to the "owner" of the function.
In the example above, this is the person object that "owns" the full_Name function.
In other words, this.first_Name means the firstName property of this object.

Accessing Object Methods:
ObjectName followed by . and methodName. In the above example person.full_name().
Object constructors:
function Person(first, last, age, eye) {
 this.first_Name = first;
 this.last_Name = last;
 this.age = age;
 this.eye_Color = eye;
//create the person objects
var my_Father = new Person("John", "Doe", 50, "blue");
Object Methods:

Copies the values of all enumerable own properties from one or more source objects to a target object.
Creates a new object with the specified prototype object and properties.
Adds the named property described by a given descriptor to an object.
Adds the named properties described by the given descriptors to an object.
Returns an array containing all of the [key, value] pairs of a given object's own enumerable string properties.
Freezes an object. Other code cannot delete or change its properties. 
Returns a new object from an iterable of [key, value] pairs. (This is the reverse of Object.entries).
Compares if two values are the same value. Equates all NaN values (which differs from both Abstract Equality Comparison and Strict Equality Comparison).
Determines if extending of an object is allowed.
Determines if an object was frozen.
Determines if an object is sealed.
Returns an array containing the names of all of the given object's own enumerable string properties.
Prevents any extensions of an object.
Prevents other code from deleting properties of an object.s.

Top comments (0)