JavaScript 101: A Comprehensive Introduction
Ayesha Gull
9/1/2023, 11:24:40 AM
3 min read
Getting started with JavaScript is easier than any other programming language. All you need is a browser to write JavaScript code. All popular browsers, including Chrome, Edge and Safari, have a set of developer tools that allow users to view information about the current web page, execute JavaScript, modify the live HTML, among other things.
What is JavaScript?
Brendan Eich created JavaScript in 1995 while working as an engineer at Netscape. It is an object-oriented programming language that facilitates interactivity within browsers without reloading pages for each action. JavaScript is a scripting language. Eich wrote the first version of the language in only 10 days.
JavaScript features:
JavaScript is a scripting language. Scripting languages do not need to undergo compilation. They rely on special run-time environments and related interpreters—computer programs that execute code without compilation through various methods. Modern web browsers include interpreters that can interpret JavaScript code.
JavaScript outside the browser:
The most popular environment you will find JavaScript outside the browser is for Node.js. Node.js is a JavaScript engine that runs without a browser in a server environment. This means you can use JavaScript to build a complete web application from the backend to the frontend. In addition, various mobile frameworks like Cordova, Ionic, and React Native allow developers to build mobile apps using web technology, including JavaScript for any scripting.
Alternatives to JavaScript:
There are few real alternatives to JavaScript for executing code in a browser. These options offer an alternative syntax to JavaScript but are compiled to pure JavaScript before we can use them in a browser. Some popular alternatives to JavaScript include CoffeeScript, TypeScript, and Dart.
When using these alternative languages, your code is translated to JavaScript, then executed in the browser.
Adding JavaScript to HTML In the experiment above, you used the console of your web browser to execute JavaScript code. The standard use of JavaScript is to add scripting to HTML pages. To do that, you need to include JavaScript in the HTML itself. When a browser detects a <script> tag in an HTML file, it knows to execute JavaScript code. Using this tag, you can either embed your JavaScript code directly in an HTML file or include a separate JavaScript source file.