Posts

Showing posts from September, 2022

Window.innerWidth

 The read-only Window property innerWidth returns the interior width of the window in pixels. This includes the width of the vertical scroll bar, if one is present. More precisely, innerWidth returns the width of the window's layout viewport. The interior height of the window—the height of the layout viewport—can be obtained from the innerHeight property. Value An integer value indicating the width of the window's layout viewport in pixels. This property is read-only, and has no default value. To change the window's width, use one of the Window methods for resizing windows, such as resizeBy() or resizeTo(). < ! DOCTYPE html > < html lang = "en" > < head > < meta charset = "UTF-8" > < meta http-equiv = "X-UA-Compatible" content = "IE=edge" > < meta name = "viewport" content = "width=device-width, initial-scale=1.0" > < title > ye < / title > ...

Class inheritance

  Class inheritance Class inheritance is a way for one class to extend another class. So we can create new functionality on top of the existing. The “extends” keyword Let’s say we have class  Animal : class Animal { constructor ( name ) { this . speed = 0 ; this . name = name ; } run ( speed ) { this . speed = speed ; alert ( ` ${ this . name } runs with speed ${ this . speed } . ` ) ; } stop ( ) { this . speed = 0 ; alert ( ` ${ this . name } stands still. ` ) ; } } let animal = new Animal ( "My animal" ) ; Here’s how we can represent  animal  object and  Animal  class graphically: …And we would like to create another  class Rabbit . As rabbits are animals,  Rabbit  class should be based on  Animal , have access to animal methods, so that rabbits can do what “generic” animals can do. The syntax to extend another class is:  class Child extends Parent . Let’s create...