Greeting All,

I hope that you are awesome guys. That blog is all about Introduce to JavaScript object where i am trying to explain to some fundamental and important topics that can be helps us to overcome our problems.

 

Introduction to JavaScript Object

First of all I want to tell you that as you know Object is the main various part of the JavaScript language. And I want to clarify that JavaScript is not similar to Java . Both  are different things. JavaScript is an Object Oriented Programming (OOP) language. A programming language can be called object-oriented if it provides some basic capabilities like : −

  1. Class : –   Class can be defined as a template or blue print that describe the behaviors or states that object of its type support. Class can be contain many object in a single class.
  2. Object :-   Object is an instance of a class . Object have states and behavior for example a dog has states like name, color as well as behavior like barking, eating etc. 
  3. Inheritance :-    Inheritance can be define as a process where one or more object acquire the properties and functionality of another class.
  4. Polymorphism :- Poly means many and morphism means form. polymorphism means many forms. We can be define as like A polymorphism is an ability to takes an object in many forms.
  5. Encapsulation :- Encapsulation is nothing but just a Technique where end user don’t know how to implement in that class, users can have to permission what to store and what to reject and that data can be read only or write only or both. In the simplest way if I have to define of Encapsulation then I can say like Encapsulation is a mechanism to wrapping the date variable and code action on the data method as a single unit .

 

Way to Creating and accessing of Object in JavaScript

 

  • first way of creating Object                                                                                                                                                                                                                                                   An Object is creating with the help of figure brackets like { …… } which has some Properties . Before creating the object with the help of figure brackets we have to know that what is the Properties . So I have been define below in simplest way to easy to understand :- 
    • properties :-   A property is a key – value pair, where key can be define as a string and value can be define anything.

Example : –  

 

  • Second way of creating Object 

                         An Object is creating with the help of constructor also. A behavior of Constrcor is just like same as a function that creates and initialize of object. And JavaScript also provides a special constructor function named  called like Object() when we use of object() at the time of build the object. The return value of the Object() constructor is assigned to a variable.

Example :-

 

  • Way to Accessing Object

First way to Accessing Object :- 

Example :-

Second way to Accessing Object

 

Next time I will come back with more advance and important topics. Thanks to all.