reading-note

https://eng-ehabsaleh.github.io/reading-note/

View on GitHub

DEFINITION OF JAVA SCRIPT

Input Output “EXAMPLE”

The very first thing we need to learn is how to interact with the JavaScript code running in the browse. There are a number of way JavaScript can display text for the user (output). The most simple one is by using the alert function

This will show a pop-up in the browser with the text. (You can click on Try! that will open the specific script in a separate window.) The alert() function is actually rarely used, but it is an easy way to show the use of JavaScript.

In this example we have some text (First line), then the JavaScript code, and then some more text (Last line). The JavaScript code uses the document.write function to change the content of the page. It will embed the html snippet <h1>Hello World</h1> after the “First line”, but before the “Last line”.

Most of the web browsers provide what is called a “JavaScript console”. It is an additional window which is normally not visible, where the browser can print out warnings and errors generated by the execution of the JavaScript code. (E.g. if there is a syntax error in the code.) The developer can also print information to this console using the console.log() call.

In order to see the console you’ll need to open it.