JavaScript is a popular object-based scripting language that is widely used for creating dynamic web pages. It is lightweight, cross-platform, and supports both beginners and professionals.
JavaScript is not a compiled language, but rather a translated language. The JavaScript translator, which is embedded in the browser, is responsible for translating the JavaScript code for the web browser.
What is JavaScript?
JavaScript (js) is a lightweight, object-oriented programming language that enables dynamic interactivity on websites when applied to an HTML document. It is an interpreted, full-fledged programming language that was first introduced in 1995 for adding programs to web pages in the Netscape Navigator browser. Since then, it has been adopted by all other graphical web browsers. With JavaScript, users can build modern web applications that interact directly with the page without reloading it every time. Traditional websites use JavaScript to provide several forms of interactivity and simplicity.
Although JavaScript has no connectivity with Java programming language, the name was suggested and provided in the times when Java was gaining popularity in the market. In addition to web browsers, databases such as CouchDB and MongoDB use JavaScript as their scripting and query language.
Features of JavaScript
JavaScript has several features, including:
- All popular web browsers support JavaScript as they provide built-in execution environments.
- JavaScript follows the syntax and structure of the C programming language, making it a structured programming language.
- JavaScript is a weakly typed language, where certain types are implicitly cast (depending on the operation).
- JavaScript is an object-oriented programming language that uses prototypes rather than classes for inheritance.
- It is a lightweight and interpreted language.
- JavaScript is a case-sensitive language.
- JavaScript is supported in several operating systems, including Windows and macOS.
- It provides good control to users over web browsers.
History of JavaScript
In 1993, Mosaic, the first popular web browser, was released. In 1994, Netscape was founded by Marc Andreessen, who realized that the web needed to become more dynamic. To achieve this, a "glue language" was believed to be provided to HTML to make web designing easy for designers and part-time programmers. Consequently, in 1995, the company recruited Brendan Eich with the intention of implementing and embedding Scheme programming language into the browser. However, before Brendan could start, the company merged with Sun Microsystems to add Java to its Navigator to compete with Microsoft over web technologies and platforms. Now, two languages were there: Java and the scripting language. Further, Netscape decided to give the scripting language a similar name to Java's, which led to "JavaScript." Finally, in May 1995, Marc Andreessen coined the first code of JavaScript named "Mocha." Later, the marketing team replaced the name with "LiveScript." However, due to trademark reasons and other factors, in December 1995, the language was finally renamed "JavaScript." From then, JavaScript came into existence.
Application of JavaScript
JavaScript is used to create interactive websites and is mainly used for:
- Client-side validation
- Dynamic drop-down menus
- Displaying date and time
- Displaying pop-up windows and dialog boxes (like an alert dialog box, confirm dialog box, and prompt dialog box)
- Displaying clocks, etc.
JavaScript Example
Here's an example of a basic JavaScript program:
javascript<script>
document.write("Hello JavaScript by JavaScript");
</script>