Javascript Tutorial for Beginners
JavaScript is a dynamic programming language that's used for
web development,It is used both on the client-side and server-side that
allows you to make web pages interactive.Where HTML and CSS are
languages that give structure and style to web pages, JavaScript gives
web pages interactive elements that engage a user.It is an interpreted programming language
with object-oriented capabilities
JavaScript was created in May 1995 in 10 days, by Brendan Eich. Eich worked at Netscape and
implemented JavaScript for their web browser, Netscape Navigator.Initially, JavaScript’s name
changed several times:
Its code name was Mocha.
In the Netscape Navigator 2.0 betas (September 1995), it was called LiveScript.
In Netscape Navigator 2.0 beta 3 (December 1995), it got its final name, JavaScript.
Why Javascript..?
All popular web browsers support JavaScript as they provide built-in execution
environments.
JavaScript follows the syntax and structure of the C programming language. Thus, it is 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 using classes for inheritance.
1
It is a light-weighted and interpreted language.
Standardizing JavaScript ECMA
ECMA-262 is hosted by Ecma International. It is the primary standard
The language described by these standards is called ECMAScript, not JavaScript. A
different name was chosen because Sun (now Oracle) had a trademark for the latter name. The
"ECMA" in "ECMAScript" comes from the organization that hosts the primary standard.
The original name of that organization was ECMA, an acronym for European Computer
Manufacturers Association. It was later changed to Ecma International (with "Ecma" being a
proper name, not an acronym) because the organization’s activities had expanded beyond
Europe. The initial all-caps acronym explains the spelling of ECMAScript
In principle, JavaScript and ECMAScript mean the same thing. Sometimes the following
distinction is made:
The term JavaScript refers to the language and its implementations.
The term ECMAScript refers to the language standard and language versions. Therefore,
ECMAScript 6 is a version of the language (its 6th edition).
2
Editio Date of Name Description
n Publishe
d
1 June 1997 ECMAScript First version of the standard
1
2 June 1998 ECMAScript Small update to keep ECMA-262 in sync with
2 the ISO standard.
3 December ECMAScript Adds many core features – regular expressions,
1999 3 better string handling, new control statements
[do-while, switch], try/catch exception handling
4 June 2003 ECMAScript (abandoned in July 2008): Would have been a
4 massive upgrade (with static typing, modules,
namespaces, and more), but ended up being
too ambitious and dividing the language’s
stewards.
5 December ECMAScript Brought minor improvements – a few standard
2009 5 library features and strict mode.
5.1 June 2011 ECMAScript Another small update to keep Ecma and ISO
5.1 standards in sync
6 June 2015 ECMAScript A large update that fulfilled many of the
2015 promises of ECMAScript 4. This version is the
(ES2015) first one whose official name – ECMAScript
2015
7 June 2016 ECMAScript First yearly release. The shorter release life
2016 cycle resulted in fewer new features compared
(ES2016) to the large ES6.
8 June 2017 ECMAScript Second yearly release.
2017
(ES2017)
9 June 2018 ECMAScript New features include the spread operator and
2018 rest parameters (...) for object literals,
(ES2018) asynchronous iteration,
3
Promise.prototype.finally and additions to
RegExp.
10 June 2019 ECMAScript Added features include, but are not limited to,
2019 Array.prototype.flat, Array.prototype.flatMap,
(ES2019) changes to Array.sort and Object.fromEntries
11 June 2020 ECMAScript In addition to new functions, this version
2020 introduces a BigInt primitive type for arbitrary-
(ES2020) sized integers, the nullish coalescing operator,
and the globalThis object.
12 June 2021 ECMAScript This version introduces the replaceAll method
2021 for strings,Promise.any,AggregateError,logical
(ES2021) assignment operators (??=, &&=, ||=),
WeakRef,FinalizationRegistry,separators for
numeric literals,Array.prototype.sor
BASIC PROGRAM
<! DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tutor Joes</title>
</head>
<body>
<script>
alert("Tutor Joes");
</script>
</body>
</html>
CONSOLE
4
The JavaScript console is a built-in object in the browser that provides access to the browser's
developer console. The developer console is a tool that allows developers to view and debug
their code, as well as run JavaScript commands directly in the browser.
In javascript, the console is an object which provides access to the browser debugging console.
We can open a console in web browser. The console object provides us with several different
methods:
log()
error()
warn()
clear()
time() and time End()
table()
count()
custom console logs
console.log("Welcome To Tutor Joes");
console.log(123456);
console.log(18.25);
console.log(true);
console.log([58,78,96,35]);
console.log({fname:'Joes',age:25});
console.table({fname:'Joes',age:25});
console.error("Custom Sample Error");
console.warn("Custom Sample Error");
console.clear();
for(i=0;i<10;i++)
{
console.log(i);
}
5
Differences Between var, let, and const in JavaScript
var
Variable means anything that can vary. In JavaScript, a variable stores the data value that can be
changed later on.
Use the reserved keyword var to declare a variable in JavaScript.
let
let cannot be Redeclared.
let must be Declared before use.
let have Block Scope.
const
const cannot be Redeclared.
const cannot be Reassigned.
const have Block Scope.
var a=25;
console.log(a)
var a=45;
console.log(a)
let a=25;
console.log(a)
let a=45;
const a=25;
console.log(a)
const a=45;
6
Arithmetic Operations
Sno Operator Usage
1. + Addition
2. - Subtraction
3. * Multiplication
4. ** Exponentiation (2016)
5. / Division
6. % Modulus (Remainder)
7. ++ Increment
8. -- Decrement
Addition (+): This operator is used to add two or more numbers together. For example, 4 +
3 will give the result of 7.
Subtraction (-): This operator is used to subtract one number from another. For example,
10 - 3 will give the result of 7.
Multiplication (*): This operator is used to multiply two or more numbers together. For
example,4 * 3 will give the result of 12.
7
Division (/): This operator is used to divide one number by another. For example, 10 / 5
will give the result of 2
Modulus (%): This operator is used to find the remainder when one number is divided by
another. For example, 10 % 3 will give the result of 1.
Exponentiation (**): This operator is used to raise a number to a certain power. For
example, 2 ** 4 will give the result of 16.