Pageviews

Wednesday, 31 July 2019

+2] 6. Client Side Scripting Using JavaScript - Previous Questions chapter wise


                         PLUS TWO COMPUTER APPLICATION

          (+2 Computer Application / Computer Science ,  
Previous Questions Chapter wise ..

                                           Chapter  6 Client Side Scripting Using JavaScript.


1. Explain three different ways to add javascripts in a webpage.

Inside <BODY>

    the scripts will be executed while the contents of the web page is being loaded. The web page starts displaying from the beginning of the document. When the browser sees a script code in between, it renders the script and then the rest of the web page is displayed in the browser window. A script can also be at the bottom of tag. If the scripts are loaded inside the tag or in the tag, they will be loaded along with the HTML code.

Inside<HEAD>

     It is a usual practice to include scripts in the head section of the web page. The main reason for this is that the body section of most of the HTML pages contains a large volume of text that specifies the contents to be displayed on the web page. Mixing a function definition also with this will create a lot of confusion for the web designer for making any kind of modification in the page.More over, the head section of a web page is loaded before the body section. Therefore, if any function call is made in the body section, the function will be executed as the function definition is already loaded in the memory.

External JavaScript file

      We can place the scripts into an external file and then link to that file from within the HTML document. This file is saved with the extension ‘.js’. Placing JavaScripts in external files has some advantages. This is useful if the same script is used across multiple HTML pages or a whole website. It separates HTML and code which makes HTML and JavaScript easier to read and maintain. Storing JavaScript as separate files can speed up page loading.

2. Briefly explain three built in functions in javascript

a. alert() function

             This function is used to display a message on the screen. For example, the statement alert(“Welcome to JavaScript”); will display the following message window on the browser window.

b. isNaN() function

        This function is used to check whether a value is a number or not. In this function, NaN stands for Not a Number. The function returns true if the given value is not a number.

For example.
isNaN(“welcome”); retun the value true.

isNaN(“13.5”); return the value false.

3. What is an external javascript file.Write the advantages of using these files.

      We can place the scripts into an external file and then link to that file from within the HTML document. This file is saved with the extension ‘.js’. Placing JavaScripts in external files has some advantages. This is useful if the same script is used across multiple HTML pages or a whole website. It separates HTML and code which makes HTML and JavaScript easier to read and maintain. Storing JavaScript as separate files can speed up page loading. the JavaScript code is stored as a separate file with the name “check.js”. 

4. In javascript

   a.  Describe any 2 datatypes used?

   b.  Explain any three operators used?

Answers.

    Number : All numbers fall into this category. All positive and negative numbers, all integer and float values (fractional numbers) are treated as the data type number. Thus, 27, -300, 1.89 and -0.0082 are examples of number type data in JavaScript.
  String: Any combination of characters, numbers or any other symbols, enclosed within double quotes, are treated as a string in JavaScript. That is, “Kerala”, “Welcome”, “SCHOOL”, “1234”, “Mark20”, “abc$” and “sanil@123” are examples of string type data.

b. Arithmetic operators, logical operators and assignment operators.

  The standard arithmetic operators are addition (+), subtraction (-), multiplication (*), and division (/),modulo division(%)

    Image result for arithmetic operators
   
      Logical operators are &&,|| and !

        Image result for logical operators
Assignment operators are

Image result for assignment operators