Javascript Comment

JavaScript comments are used to explain the JavaScript code logic. JavaScript comments are ignored by JavaScript translators. It makes JavaScript code more readable. Types of JavaScript comments: 1. Single-line Comment 2. Multi-line Comment JavaScript Single-line Comment: The double forward slashes (//) are used for Single line comments. Anything between // to the end of the … Read more

JavaScript Examples

Before starting an example let us discuss how JavaScript can display the data. JavaScript ways of data display: 1. window.alert(): Display data in an alert box. 2. document.write(): Display data into the HTML output. 3. innerHTML: Display data into an HTML element. 4. console.log(): Display data into the browser console. Javascript in head tag example: … Read more

JavaScript Syntax

JavaScript Syntax specifies the set of rules for constructing a JavaScript program. The is used to write JavaScript statements. The script tag can be used anywhere in the head or body but it is a good practice to use it within the tag. Syntax: <script language=”javascript” type=”text/javascript”> //JavaScript statements </script> Attributes: language: represents the Java … Read more