Loop (For) With JavaScript

 Loop (For) With JavaScript


A. Understanding JavaScript

JavaScript is a language used to create programs that are used to make HTML documents displayed in a browser more interactive, not just beautiful. JavaScript provides some functionality into a web page, so it can be a program that is served using a web interface.

 

Also Read: How to Create a Control IF Using JavaScript

JavaScript is a scripting language, which is a language that does not require a compiler to run it, but only with an interpreter. There is no need for a compilation process before the program can run. The Netscape Naviagtor web browser and Internet Explorer are examples of one of the many interpreters, because both browsers are equipped with a JavaScript Interpreter. But not all web browsers can be a javascript interpreter because not necessarily the browser is equipped with a JavaScript interpreter.

 

JavaScript is a programming language that is lightweight and easy to use. With this JavaScript, now a web page is not just a data and information page, but also an application program with a web interface.

 

To run javascript, we only need a text editor application, and a web browser. Javascript has the following features: high-level programming language, client-side, loosely typed, and object-oriented.

There are 3 ways to write javascript tags, namely;

    1. Write a tag starting with <script type="text/javascript"> and ending with a </script> attribute that informs the browser that the script program contained in the tag is javascript in text format.
    2. Write tags starting with <script language="javascript"> and ending with </script> this attribute is used to determine the version of javascript used, for example <script language="javascript1.2"> states that the javascript we use is version 2.1.
    3. Writing tags starting with <script language="javascript" type="text/javascript"> and endingwith </script> this mixed method, namely old writing and new writing, is done to anticipate web page accessors who still use a web browser that supports javascript, but doesn't support HTML yet.


Javascript Functions

Javascript allows web programming to:

Has a programming tool on the web.

• Read and write HTML elements into a web page. JavaScript programs can change the content of the web element that is currently being displayed.

• Make web pages more dynamic, because we can also insert web elements into javascript.

• Give a reaction to an event on the web page that is being displayed, for example there is an event that the right mouse button is clicked on a web page, then with javascript we can add a program so that a reaction or execution of a certain program is carried out if there is an event of pressing the mouse button.

• Turning a web page into a web-based application that can run on top of a web browser. The web page is not only a display of data and information, but also an application to interact with its users, process data in the browser, receive and validate data before it is sent to the server.

• Detect the browser used by the user, so that we can present information related to the web browser used by the user.

• Create a cookie, or a code that is used to store and retrieve data and information from a visitor's browser.

As with other programming, it certainly will not escape the For, for is an iteration of each data element. For more details, type the following For example then save it with the name for.html.

DATA HOSTED WITH ♥ BY PASTEBIN.COM - DOWNLOAD RAW - SEE ORIGINAL

  1. <html>
  2. <head>
  3. <title>For</title>
  4.  <script language="JavaScript">
  5.   for (var i=1 ; i<6 ; i++)
  6.  {document.write(i+ "<br>")}
  7.  </script>
  8. </head>
  9. <body>
  10. <!-- menampilkan kode HTML -->
  11. </body>
  12. </html>


So how…? do you now understand looping (For) with JavaScript? Maybe that's all the writing that discusses Loop (For) with JavaScript, if there are shortcomings or errors in writing, please forgive and correct or complete it if there are errors.

Post a Comment

Previous Post Next Post