JavaScrpt, also known as JS for short, is a lightweight, interpreted (i.e. no need to compile) and prototype-based, multi-paradigm, dynamic scripting language that simultaneously supports object-oriented, imperative, and declarative as well as functional programming styles.
Netscape, meanwhile, introduced the language to Ecma International (a European standard-setting body) – the first version of ECMAScript was released in 1997. This standard was further developed in 1999 as ECMAScript version 3 – and the language has not changed much since then.
The fourth edition is ruined, as a result of disagreements over the complexity of the language. However, the fifth edition of the new ECMAScript was released in 2009 on the basis of many parts of this fourth edition. ECMA International last released its sixth major edition on June 16, 2015,
Officially called ECMAScript 2015, and is now known as ECMAScript 6 or ES6.
What are Web Console and Scratchpad?
You can use Ctrl + Shift + I to easily run Web Console in firefox and chrome browser. Then the following output will appear:
The main problem with Web Console is that it allows you to execute single line code, on the other hand you can execute live code in one line on Scratchpad if you want. You can use Shift + F4 to run Scratchpad in firefox browser. And you can use Ctrl + Shift + I to run Scratchpad easily in chrome browser. After running Scratchpad you will see the following:
Run between <script> start tag and </script> end tag:
If you click on the first button here, the word Hello Bangladesh in your p tag will be changed to Hello World, and if you click on the second button, you will get an alert.
First, type the following code into the script.js file:
Now type the following code in test.html file:
Notice here, we have used jquery CDN in line 12 of test.html file, and we have attached script.js file in local pc in line 13.
1. Via the alert box using window.alert ()
2. Write to HTML document using document.write ()
3. Write to HTML element using .innerHTML
4. Can be shown in the browser console using console.log ()
Use window.alert ()
You can use the alert box to display information
Use document.write ()
We can show any output using document.write (). However, one thing to keep in mind is that after the HTML Element is fully loaded, using document.write () deletes all previous HTML:
Note: The document.write () method should only be used for testing.
The id attribute of HTML tags points to a specific element of HTML and can point to any HTML content through the innerHTML Property. Let’s understand with an example:
using console.log ()