Page 225 - Web Applications (803) Class 12
P. 225

student.age = 35;
                           student.Address = "Ajmer";
                     6.  Explain the following with respect to Java script using suitable example.
                      i.  Event handler                                 ii.  Objects
                      iii.  Operator
                  Ans.  i.   Event Handler: The "event handler" is a command that is used to specify actions in response to an event. Eg:
                         onLoad, onMouseover etc.
                       ii.  Objects: JavaScript objects are simply collections of name-value pairs. The "name" part is a JavaScript string,
                         while  the  value  can  be  any  JavaScript  value  including  more  objects.  Objects  are  a  way  of  organizing  the
                         variables. The different screen elements such as Web pages, forms, text boxes, images, and buttons are treated
                         as objects.
                       iii.  Operator: Operators are symbols which perform some operation on values. JavaScript operators can be used
                         to perform various operations such as:
                           Arithmetic Operators                          Comparison Operators
                           Logical Operators                             Relational Operators

                           Assignment Operators                          Conditional Operator
                     7.  Define the characteristics of JavaScript. Are Java and JavaScript similar? Write the difference between them.
                                                                                                          [CBSE Handbook]
                  Ans.  The features of JavaScript are as follows:
                          The original purpose of JavaScript was DOM manipulation. Prior to the creation of JavaScript, the majority of
                         earlier websites were static.

                          In JavaScript, functions are objects. They might have methods and characteristics similar to those of another
                         object. Other functions may accept them as arguments.

                         Can manage time and date manipulations.
                         Though forms are constructed using HTML, JavaScript helps perform form validation.
                         A compiler need not be installed separately.
                       Java and JavaScript are not similar. The difference between the two is as follows:
                                              Java                                          JavaScript
                       Since variables in Java must be declared before being  JavaScript  is a  loosely typed  language  and  has  less
                       used in a program, it is a tightly typed language. The  strict rules and syntax.
                       type of a variable is verified at build time in Java.
                       Any  virtual  machine  (JVM)  or  browser  can  run  Java  Only the browser can execute JavaScript code.
                       applications.
                         Java is an independent language.                A web page has JavaScript that is integrated with the
                                                                         HTML code on it.

                     8.  Write JavaScript statements for the following:
                      i.  To store date and time in a variable and then display date and time on the webpage.
                      ii.  To search “sat” in the string “Humpty Dumpty sat on a wall” and display it on the webpage.
                      iii.  Perform the following actions on an array col containing the following: [“red”, “green”, “blue”]
                          a.  Add “silver” to the array col
                          b.  Join array col to another array fruits containing [“apple”, “orange”]

                          c,  Sort the array col
                          d.  Display the array col in reverse


                                                                                          Web Scripting—JavaScript   223
   220   221   222   223   224   225   226   227   228   229   230