Posts

Showing posts with the label javascript keywords

javascript's - this keyword, getters & setters, Dom box dimension properties

Image
  JavaScript Today’s topic - this keyword, Getters & Setters,  Dom box dimension properties. This keyword this keyword’s  simple description would be it refers to the object in which it is used. this can give different values based on where it has been used. Global context - In global context  i.e used outside of any function this will refer to the global object. this in a global context. Function context - When this keyword is used in the function in non strict mode this will refer to the global object . this in a function context. Function context (“strict mode”) - When  this keyword is used in the function context in strict mode this will be undefined. this in a function context using strict mode. Method context - While used in method context this refers to the owner of the method in which it is used. this in a method context. Event context -   When used in an event context this will refer to the element by which the event is called. this...

javaScript's - inheritance, super keyword, new keyword

Image
JavaScript’s (OOJS) Today’s topic - Inheritance, Super keyword, New keyword. Inheritance -  Inheritance basically means to create a child class which has access to a parent class or base class. The child class inherits all the methods from its parent class.  To create a class inheritance we use the Extends keyword. Inheritance is basically great for code reusability.  WHY? Because  you can use the properties and methods of the parent class in the child class. Super keyword -  So basically the super() keyword is only available to classes. The super() always refers to the parent class constructor. By calling the super() method in the constructor of the child class you call the parent class constructor and get access to parent properties and methods. If there is a constructor in the child class the super() method should be used before this() keyword otherwise it will cause a reference error. New keyword -   The new keyword is basically used to create an i...