0% found this document useful (0 votes)
7 views

Introduction-to-JS 1

Uploaded by

texidoy318
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Introduction-to-JS 1

Uploaded by

texidoy318
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

JavaScript

Topperworld.in

Introduction to JS

⚫ JavaScript (js) is a light-weight object-oriented programming language which


is used by several websites for scripting the webpages.

⚫ It is an interpreted, full-fledged programming language that enables


dynamic interactivity on websites when applied to an HTML document.

⚫ It was introduced in the year 1995 for adding programs to the webpages 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 to interact directly
without reloading the page every time. The traditional website uses js to
provide several forms of interactivity and simplicity.

Syntax:
<script>
// JavaScript Code
</script>

©Topperworld
JavaScript

❖ History of JavaScript

It was created in 1995 by Brendan Eich while he was an engineer at


Netscape.

◆ It was originally going to be named LiveScript but was renamed. Unlike


most programming languages, JavaScript language has no concept of
input or output.

◆ It is designed to run as a scripting language in a host environment, and


it is up to the host environment to provide mechanisms for
communicating with the outside world.

◆ The most common host environment is the browser.

❖ JavaScript Versions
o JavaScript is a modern scripting language that is popular worldwide
among developers.

o It is a lightweight, interpreted compiled language that can be used on


both client-side as well as the server side. It was invented in the year
1995 by Brendan Eich.

o Over the years the language has improved a lot and a lot of new features
have been added which make the coding process even easier. This
language became an ECMA standard in the year 1997.

©Topperworld
JavaScript

Version Name Release Year Features

ECMAScript
ES1 1997 Initial Release
1

ECMAScript
ES2 1998 Minor Editorial Changes
2

Added:

• Regular Expression
ECMAScript
ES3 1999 • try/catch
3
• Exception Handling
• switch case and do-while

ECMAScript
ES4 Abandoned due to conflicts
4

Added:

ECMAScript • JavaScript “strict mode”


ES5 2009
5 • JSON support
• JS getters and setters

Added:

ECMAScript • let and const


ES6 2015
2015 • Class declaration
• import and export

©Topperworld
JavaScript

Version Name Release Year Features

• for..of loop
• Arrow functions

Added:

• Block scope for variable


ECMAScript
ES7 2016 • async/await
2016
• Array.includes function
• Exponentiation Operator

Added:

ECMAScript • Object.values
ES8 2017
2017 • Object.entries
• Object.getOwnPropertiesDescriptors

Added:
ECMAScript
ES9 2018 • spread operator
2018
• rest parameters

Added:

ECMAScript • Array.flat()
ES10 2019
2019 • Array.flatMap()
• Array.sort is now stable

©Topperworld
JavaScript

Version Name Release Year Features

Added:
ECMAScript
ES11 2020 • BigInt primitive type
2020
• nullish coalescing operator

Added:
ECMAScript
ES12 2021 • String.replaceAll() Method
2021
• Promise.any() Method

Added:

ECMAScript • Top-level await


ES13 2022
2022 • New class elements
• Static block inside classes

ES.Next Dynamic name for upcoming version.

❖ First JavaScript Program


So before moving on further.. let’s do the most popular ‘Welcome’
tradition .

<html>

<body>
<!-- JavaScript code can be embedded inside
body section -->

<script>

©Topperworld
JavaScript

console.log("Welcome to Topperworld");
</script>
</body>

</html>

Output: The output will display on the console.

Welcome to Topperworld

❖ Link JavaScript File in HTML


JavaScript can be added to HTML file in two ways:

✓ Internal JS: We can add JavaScript directly to our HTML file by


writing the code inside the <script> tag. The <script> tag can either
be placed inside the <head> or the <body> tag according to the
requirement.

✓ External JS: We can write JavaScript code in another files having


an extension.js and then link this file inside the <head> tag of the
HTML file in which we want to add this code.

❖ Features of JavaScript
o According to a recent survey conducted by Stack Overflow, JavaScript is
the most popular language on earth.

©Topperworld
JavaScript

o JavaScript was created in the first place for DOM manipulation. Earlier
websites were mostly static, after JS was created dynamic Web sites
were made.
o Functions in JS are objects. They may have properties and methods just
like other objects. They can be passed as arguments in other functions.
o Can handle date and time.
o Performs Form Validation although the forms are created using HTML.
o No compiler is needed.

❖ Applications of JavaScript

 Web Development: Adding interactivity and behavior to static sites


JavaScript was invented to do this in 1995. By using AngularJS that can
be achieved so easily.

 Web Applications: With technology, browsers have improved to


the extent that a language was required to create robust web
applications. When we explore a map in Google Maps then we only
need to click and drag the mouse. All detailed view is just a click away,
and this is possible only because of JavaScript.

 Server Applications: With the help of Node.js, JavaScript made its


way from client to server and Node.js is the most powerful on the server
side.

©Topperworld
JavaScript

 Games: Not only in websites, but JavaScript also helps in creating


games for leisure. The combination of JavaScript and HTML 5 makes
JavaScript popular in game development as well. It provides the EaseJS
library which provides solutions for working with rich graphics.

 Smartwatches: JavaScript is being used in all possible devices and


applications. It provides a library PebbleJS which is used in smartwatch
applications. This framework works for applications that require the
Internet for their functioning.

 Art: Artists and designers can create whatever they want using
JavaScript to draw on HTML 5 canvas, and make the sound more
effective also can be used p5.js library.

 Machine Learning: This JavaScript ml5.js library can be used in web


development by using machine learning.

 Mobile Applications: JavaScript can also be used to build an


application for non-web contexts. The features and uses of JavaScript
make it a powerful tool for creating mobile applications. This is a
Framework for building web and mobile apps using JavaScript. Using
React Native, we can build mobile applications for different operating
systems. We do not require to write code for different systems. Write
once use it anywhere!

©Topperworld
JavaScript

❖ Advantage of JavaScript

 Less server interaction: You can validate user input before sending
the page off to the server. This saves server traffic, which means less
load on your server.

 Immediate feedback to the visitors: They don't have to wait for


a page reload to see if they have forgotten to enter something..

 Increased interactivity: You can create interfaces that react when


the user hovers over them with a mouse or activates them via the
keyboard.

 Richer interfaces: You can use JavaScript to include such items as


drag-and-drop components and sliders to give a Rich Interface to your
site visitors.

❖ Limitations of JavaScript

 Security risks: JavaScript can be used to fetch data using AJAX or by


manipulating tags that load data such as <img>, <object>, <script>.
These attacks are called cross-site script attacks. They inject JS that is not
part of the site into the visitor’s browser thus fetching the details.

©Topperworld
JavaScript

 Performance: JavaScript does not provide the same level of


performance as offered by many traditional languages as a complex
program written in JavaScript would be comparatively slow. But as
JavaScript is used to perform simple tasks in a browser, so performance
is not considered a big restriction in its use.

 Complexity: To master a scripting language, programmers must have


a thorough knowledge of all the programming concepts, core language
objects, and client and server-side objects otherwise it would be difficult
for them to write advanced scripts using JavaScript.

 Weak error handling and type checking facilities: It is a


weakly typed language as there is no need to specify the data type of the
variable. So wrong type checking is not performed by compile.

©Topperworld

You might also like