Open In App

What is JavaScript ?

Last Updated : 20 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

JavaScript is a single-threaded, synchronous programming and scripting language. It is widely used in the field of web development. it can be used in the front end and backend. Also, JavaScript is not a compiled language, it gets interpreted through a web browser. This is how what-is-javascript

It is a loosely typed/weakly typed or dynamically typed language which means the type of the variables will be decided at the runtime. JavaScript is used to enhance the interactivity of web pages by helping in dynamically updating the content, performing operations on click-to-buttons, setting timely updation in the content, etc.

History of JavaScript

In 1933, the first popular web browser, Mosaic, was created. In the year 1994, Netscape was founded by Marc Andreessen. He wanted to make the web more interactive, so they looked for a way to add a programming language to web pages. They hired Brendan Eich to work on this, planning to use a language called Scheme. But before they could start, Netscape merged with Sun Microsystems. Sun wanted to add Java to Netscape’s browser to compete with Microsoft. Now, Netscape had two languages in mind: Java and the new scripting language. To avoid confusion, Netscape decided to give the scripting language a similar name to Java’s. They initially called it “LiveScript”, but later changed it to “JavaScript”. The first version was called “Mocha” by Marc Andreessen, but it was renamed to “JavaScript” in December 1995 due to trademark and other reasons. And that’s how JavaScript came to be.

Different ways of including JavaScript in HTML

To use JavaScript in a web page we need to include it inside the HTML document. The below ways can be used to include a JavaScript file in an HTML document.

Using the Internal JavaScript:

Internal JavaScript is the JavaScript code that is written inside the HTML document using the script tag. The script tag that contains the JavaScript code can be defined either inside the body tag or head tag. It is recommended to write the internal JavaScript code at the end of the body tag.

Syntax:

<script>
// JavaScript Code here
</script>

Using the External JavaScript:

The external JavaScript code is written in a external JavaScript file with the .js extension. The JavaScript file can be included in the HTML using the script tag with the src attribute to specify the path of the external script file so that the script written in that file can be executed.

Hello World in JavaScript

We will print the “Hello World” in the console.

Javascript




// First program of JavaScript
console.log("Hello World");


Output

Hello World

Application of JavaScript

These are the following applications of JavaScript that are used in browser for dynamic behavior:

  • Dynamic drop-down menus
  • Modal boxes and popups
  • For displaying the Date and Time on the screen
  • For displaying the Digital clocks
  • Used for validation on Client-side
  • Dynamic behaviour of buttons and links

Advantages of using JavaScript

The scripting language provide us with multiple advantages of using it. Some of them are discussed below:

  • Easy to learn: It is very easy to learn language as its syntax is very simple when comapre to other programming languages like Java, C++, C etc. Its simple syntax make it easy for beginners to understand and start developing the websites quickly.
  • Client-side scripting: JavaScript is a client-side scripting language used to enhance the interactivity of the web page by dynamically updating the content and other functions as well.
  • Support for asynchronous programming: JavaScript is a single threaded synchronous language but it also supports asynchronous programming without blocking the execution of the code. It is mainly used for sending network requests.
  • Supports server-side development: JavaScript can also be used in server side scripting using its backend framework NodeJS.
  • Versatility: JavaScript is a very versatile language as it supports both Object Oriented and the functional Programming. It can also be used to write client-side and the server-side scripting.
  • Community Support: A large community of developers uses JavaScript to develop web applications which leads to a better knowledge sharing, collaboration and developing open source tools and resources.

Limitations of JavaScript

  • JavaScript does not support multi-threading and multiprocessor capabilities. That limits the parallel work flow.
  • It can not be used for networking applications because it does not support or provide any module to execute this.
  • When JavaScript is used on client-side, It does not allow to write or read files because of security reasons.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads