Learning Java Script Fundamentals

0
1191
Learning JavaScript Fundamentals

In this session we will study the fundamentals of Java script which will teach us how to display the text in a browser window, implement looping statements(for,while,do while),Functions and arrays.

  • To understand the Java script fundamentals follow the step given below :

  1. For adding java script to an HTML page we can embed the code in two ways:
    1. Internally(i.e within your same page).
    2. Externally(i.e we can import from outside the java script file.

  2. Now write the following code in Notepad++.

  3. After writing the code the Notepad++ window will look like as shown below :

  4. After you run it on the web browser you will have the following output :

  5. We can print the text on browser using document.write statement as shown in the code below,so write the following code in Notepad++:

  6. The code in Notepad++ will look like as shown below :

  7. Thus after you open it using the web browser you will have the following output :

  8. Looping statements in Java are as follows :
    1. For statement
    2. While statement
    3. Do.. while statement
  9. For implementing the FOR STATEMENT in Java write the following code in Notepad++.

  10. Now your Notepad++ window will look like as shown below:

  11. The output of window will look like as shown :

  12. For implementing WHILE STATEMENT in Java script write the following code in Notepad++:

  13. You will have the following view of the window :

  14. The output of it is given below:

  15. The do.. while loop work similar to while loop but it initializes the variable and statement within the do block then check the condition of the while loop.

    Syntax :

  16. For example of do…While loop write the following code in Notepad++:

  17. Your Notepad++ window will look like as shown below:

  18. The output will be as follows :

  19. For implementing functions in Java script use the syntax given below :

    Syntax:- CREATE THE FUNCTION


    Syntax:- CALL THE FUNCTION

  20. Write the following code in Notepad++ to display the function.

  21. The view of Notepad++ after inserting the code will look like as shown below:

  22. The output of the code will be as shown below:

  23. For implementing Array in Java script, write the following code in Notepad++ to display the array:

  24. Now your Notepad++ window will have the following view after writing the code:

  25. You will get the following window as the output after you open it in the web browser.

  26. Thus we have studied about the Java Script Fundamentals.

LEAVE A REPLY

Please enter your comment!
Please enter your name here