/  Technology   /  JAVA SCRIPT
js3

JAVA SCRIPT

 

What is JavaScript?

JavaScript is a case sensitive language & client-side scripting language helps in making interactive web pages or adding dynamic data to the web page. JavaScript is interpreted and executed on the client machine that is on the web browser.

JavaScript is used as a default scripting language for HTML pages.

JavaScript reduces the load on the server. If we require to calculate the multiplication of 2 numbers, then it is not necessary to instruct the server to perform multiplication. JavaScript can perform multiplication by itself and final result will displayed on the web browser. Like this manner it lessened the burden to the servers.

JavaScript is rich in operators and loops. Client side scripting can be performed by using JavaScript thereby reducing the load on the web servers.

JavaScript is lightweight language i.e. a computer program that is designed to have a small RAM usage and low CPU usage, overall a low usage of system resources.

How is Java script code written?

To write a JavaScript code we require an HTML document. HTML document is host to Java Script code. If you want to execute java script code, we need to have an HTML document.

What is HTML?

The Hyper Text Mark-up Language or HTML is the standard mark-up language for documents designed to be displayed in a web browser. Web browsers include a parser to read html code. A parser is a software component that takes input data (frequently text) and builds a data structure.

What is the Use of JavaScript?

We can design web pages by using HTML itself, but most of the time it is a static file. Static file means whatever we add on the body part that will be rendered by the HTML file and will be displayed on the browser.  We cannot get dynamic data on web browsers using plain HTML document. We can overcome this drawback by using JavaScript. So the need of JavaScript is to add dynamic data to the HTML document.

Which Browser Supports JavaScript?

The best browser to run JavaScript code is Google Chrome. It has many debugging tools.

How do we embed a JavaScript code in the HTML document?

There are 2 ways to embed JavaScript in HTML document. One is internal embed another one is external. Like many HTML tags head tag, body tag, paragraph tag we have script tag also. Script tag helps us to embed JavaScript code in the HTML document.

Internal Embed Script Example:

<body>
    <p id="total"></p>
    <script>
        const price1 = 5;
        const price2 = 6;

        let result = price1 + price2;
        document.getElementById("total").innerHTML = result

    </script>
</body>

External Embed Script Example:

<body>  
    <p id="total"></p>
       <script src="script.js">
        </script>
</body>

JavaScript code can be inserted externally, in files having the .js extension

We can directly write filename, when JavaScript file and HTML file both reside in a same folder.

Example:

   <script src="script.js">

For accessing external files from different folders use the path where the JavaScript file is located.

If it does not reside in the same folder we should mention its absolute path or relative path.

Example:

<script src="d:js/script.js">

 

Leave a comment