All documentation is designed and created by JAVASCRIPT.INFO
When JavaScript was created, it initially had another name: "LiveScript". But Java was very popular at that time, so it was decided that positioning a new language as a "younger brother" of Java would help.
But as it evolved, JavaScript became a fully independent language with its own specification called ECMAScript, and now it has no relation to Java at all.
Today, JavaScript can execute not only in the browser, but also on the server, or actually on any device that has a special program called the JavaScript engine.
The browser has an embedded engine sometimes called a "JavaScript virtual machine".
Different engines have different "codenames". For example:
V8 -- in Chrome, Opera and Edge.
SpiderMonkey -- in Firefox.
...There are other codenames like "Chakra" for IE, "JavaScriptCore", "Nitro" and "SquirrelFish" for Safari, etc.
The terms above are good to remember because they are used in developer articles on the internet. We'll use them too. For instance, if "a feature X is supported by V8", then it probably works in Chrome, Opera and Edge.
ECMAScript is commonly used for client-side scripting on the World Wide Web, and it is increasingly being used to write server-side applications and services using Node.js and other runtime environments.
ECMAScript Language Specification, defines the ECMAScript Language specifies only language syntax and the semantics of the core application programming interface (API), such as Array, Function, and globalThis, while valid implementations of JavaScript add their own functionality such as input/output and file system handling.
A JavaScript is the script language of the web.
JavaScript is used to create client side dynamic page. It is object-oriented script language, whic is light weight and cross plateform.
JavaScript is not a compiled language, but is a translated language. The JavaScript Translator is responsible for translating the JavaScript code for the web browser.
What is JavaScript ?
JavaScript is a light-weight Obect-Oriented programming language which is used by several website for scripting the webpages. It is an interprated, FUll fledge programming language that enable dynamic intractive on websiteswhen applied to an HTML document.
in addition to web browser, database such as Couch DB and MongoDB uses JavaScript as their scripting and query language.
Feature of JavaScript
- All popular web browser support JavaScript as they provide build-in execution environments.
- JavaScript follows the syntax and structure of C Programming language. Thus, it is a Structured Programming Language.
- JavaScript is a weakly typed language language, where certain types are implectly cost.
- JavaScript is weakly typed language, where certain types are implecitly cost.
- JavaScript is an Object-Oriented programming language it is also use a prototype rather then using class and inheritance.
- It is a light weight and interprated language.
- It is a case-sensitive language.
- JavaScript is supportable in several operating system including WINDOWS, macOS etc.
- It provide a good control to the users the web browser.
Application of JavaScript
- Client Side Validation.
- Dynamic drop-down menus.
- Displaying Date and Time.
- Displaying pop-up windows and dialog boxes.
- Displaying clockes etc.
JavaScript Example
A simple example of JavaScript:
<script type="type/javascript">
document.write("Arjun Tripathi");
</script>
- Create a JavaScript file. You can use any text editor to do this.
- Write your JavaScript code in the file.
- Save the file with a .js extension.
- Open the JavaScript file in a web browser.
- The JavaScript code will be executed by the browser.
Here are some additional ways to run JavaScript:
-
You can run JavaScript in the console of a web browser. To do this, open the developer tools of the browser and click on the Console tab. Then, you can type your JavaScript code in the console and press Enter to run it.
-
You can run JavaScript from the command line. To do this, you need to install Node.js on your computer. Once you have installed Node.js, you can run JavaScript scripts by typing node <filename.js> in the command line.
Here is an example of a simple JavaScript code:
console.log("Hello, world!");
This code will print the message "Hello, world!" to the console of the web browser or the command line.
- Create an HTML file. You can use any text editor to do this.
- Write your JavaScript code between the
<script>
and</script>
tags. - Save the file with a .html extension.
- Open the HTML file in a web browser.
- The JavaScript code will be executed by the browser.
Here is an example of a simple JavaScript code in HTML:
<html>
<head>
<title>My HTML Page</title>
</head>
<body>
<script>
console.log("Hello, world!");
</script>
</body>
</html>
Use code with caution. Learn more
This code will print the message "Hello, world!" to the console of the web browser.
Here are some additional things to keep in mind when running JavaScript in HTML:
- The
<script>
tag can be placed anywhere in the HTML file, but it is typically placed in the<head>
or<body>
section. - The
<script>
tag can contain both JavaScript code and external JavaScript files. - If you are using an external JavaScript file, you need to specify the file path in the src attribute of the
<script>
tag.