JavaScript:
JavaScript is one of the three languages all web developers must learn. Web pages are not the only place where JavaScript is used. Many desktop and server programs use JavaScript. Ex: Node.js. Some databases like MongoDB and CouchDB also use JavaScript as their programming language.
JavaScript and Java are completely different languages, both in concept and design. JavaScript was invented by Brendan Eich in 1995, and became an ECMA standard in 1997. ECMA-262 is the official name of the standard. ECMAScript is the official name of the language.
Syntax:
<script>
/* write your script here */
</script>
Scripts can be placed in the <body> or in the <head> section of an HTML page, or in both. Scripts can also be placed in external files. External scripts are practical when the same code is used in many different web pages. JavaScript files have the file extension .js.
To use an external script, put the name of the script file in the src attribute of a <script> tag.
<script src="myScript.js"></script>
External JavaScript Advantages:
1. It separates HTML and code.
2. It makes HTML and JavaScript easier to read and maintain.
3. Cached JavaScript files can speed up page loads.
JavaScript can display data in different ways:
1. Writing into an HTML elements, using innerHTML.
2. Writing into the HTML output using document.write().
3. Writing into an alert box, using window.alert().
4. Writing into the browser console, using console.log().