Page 216 - Web_Application_v2.0_C12_Fb
P. 216

Do you know?


                      Many programmers hold the opinion that JavaScript is extremely slow and that using it for more code
                      than necessary could negatively impact performance. It's sort of true. The performance itself and the
                      project's quality can both be negatively impacted by inefficient use of this language.






                                                                                           21 st  Century   #Technology Literacy
                                              Lab Assignment ‘n Activity                       Skills



                  Complete the following activities and tick on the circle.
                    Accept a string from the user and display “Hello <Name>” in an alertbox.

                    Accept a number from the user and display its square and cube on the webpage.
                    Accept five numbers from the user and display the largest number in an alertbox.




                2.7 OBJECT-ORIENTED PROGRAMMING PRINCIPLES

              Object-Oriented Programming is a way of writing code that focuses on objects, things that have properties
              (characteristics) and methods (actions they can do). It helps to organise code, making it easier to understand,
              reuse, and maintain.
              Key Principles of OOP are as follows:

                Encapsulation: Encapsulation is the concept of hiding the implementation details of an object from the
                 outside world and only exposing the necessary information through public methods. It helps to protect
                 the internal state of an object from external interference and misuse.
                Abstraction: Abstraction is the concept of showing only the necessary information to the outside world
                 while hiding the implementation details. It helps to reduce complexity and improve modularity by exposing
                 only the essential features of an object.

                Inheritance: Inheritance is the concept of creating a new class based on an existing class. The new class
                 inherits the properties and methods of the existing class and can also add new properties and methods or
                 override the ones inherited from the parent class.
                Polymorphism: Polymorphism is the concept of having multiple forms of a method or property. It allows
                 objects of different classes to be treated as objects of a common superclass, enabling more flexibility and
                 generic code.


                2.8 OBJECTS IN JAVASCRIPT


              In JavaScript, almost everything is an object with the exception of six things: null, undefined, strings, numbers,
              booleans, and symbols. These are known as primitive types. An object is anything that isn’t a primitive value.
              This  covers  constructors,  functions,  and  arrays. Yes!  we  will  see  later  in  the  chapter,  objects  also  include
              functions and arrays.



                214   Touchpad Web Applications (Ver. 2.0)-XII
   211   212   213   214   215   216   217   218   219   220   221