Posts

Java Script

What is OOPS in Java Script? The two important principles with OOPS in java-script are Object Creation patterns(Encapsulation) and Code Reuse Patterns(Inheritance). How to use in class? Javascript does not contain class statement. Javascript is a prototype based language. Javascript  uses functions as classes. Defining a class is easy as defining a function.In the example below we define a new class called as Car. function Car() { } var car1=new Car(); var car2=new Car(); For creating instances of any class i.e. objects use new keyword.In the above snippet we have created 2 instances of object class. Constructor in java-script Constructor is a method that is used to initiate the properties of any class instance.Thus a constructor gets called when any class is instantiated. As in java-script there is no class keyword and function serves as class definition, there is no need of defining constructor explicitly. The function defined for class acts as constructo