JavaScript Session 1
JavaScript Session 1
Lecture-1
Introduction to JavaScript
● ECMAScript (or ES) is a JavaScript standard meant to ensure the
interoperability of web pages across different web browsers. It is
standardized by Ecma International according to the document
ECMA-262.
● ECMAScript 2015 was the second major revision to JavaScript.
● ECMAScript 2015 is also known as ES6 and ECMAScript 6.
2
Where to Compile and Run codes?
● On Browser
● On local(Node Js)
3
Statements & Comments
console.log(‘hi’);
var a = 5;
if (a === 5) {
console.log('value of a is 5');
}
// this is a comment
/* this is another comment */
/**
* this is a
* multiline comment
*/
4
Variables
var a = 5;
let b = 6;
const myName = “Khan”;
const areWeReady = true;
let fifthLetter = ‘e’;
var passMarks = 33.00;
● Why we are using var, let, and const for doing the same thing?
● What are the differences among these three???
● Can we put a space between fifth and Letter??
● Can’t we just name it like 5thLetter?
5
Operators
let a = 7;
let b = 4;
let c = a + b;
● Arithmetic Operators
● Assignment Operators
● Comparison Operators
● Conditional Operators
● Type Operators
6
Arithmetic Operators
● + Addition
● - Subtraction
● * Multiplication
● / Division
● % Modulus
● ** Exponentiation(^)
● ++ Increment
● -- Decrement
7
Assignment Operators
● = p=q p=q
● += p += q p=p+q
● -= p -= q p=p-q
● *= p *= q p=p*q
● /= p /= q p=p/q
● %= p %= q p=p%q
● **= p **= q p = p ** q
8
Comparison Operators
● == equal to
● === equal value and equal type
● != not equal
● !== not equal value or not equal type
● > greater than
● < less than
● >= greater than or equal to
● <= less than or equal to
● ? ternary operator
9
Conditional Operators
● && logical and
● || logical or
● ! logical not
10
Type Operators
● typeof Returns the type of a variable
● instanceof Returns true if an object is an instance of an object type
11
Data Types
1. String
2. Number
3. Bigint
4. Boolean
5. Symbol
6. Object (Object, Array, Date)
7. Undefined
8. Null
12
Conditional Statements
const num1 = 5;
const num2 = 6;
13
Conditional Statements
const jerseyNum = 7;
const jerseyColor = 'white';
14
Conditional Statements
const marks = 110;
15
Conditional Statements
const marks = -10;
let grade = null;
16
Conditional Statements
const jerseyNum = 7;
const jerseyColor = "white";
if (jerseyNum === 7) {
if (jerseyColor === "white") {
found = true;
}
}
17
Conditional Statements
const a = 4;
const b = 6;
const c = 5;
let max = a;
if (max < b) {
max = b;
}
if (max < c) {
max = c;
}
console.log(max);
18
Thank you
19