JavaScript is a programming language.we use it to give instructions to computer.
JavaScript Topic:
● Variable
● Datatype
● Operators
● Conditional statements
● Loop
● String
● Object
● Array
● Function
● Method
● Documents object model
● Events
● Classes
● Object
● Callbacks
● Promise
● Async Await
To print something in JavaScript:
Console.log(“string”)
Console.log(num)
★comments:
Single Line comment:
//This a JavaScript note
Multiline comments:
/*This is a JavaScript note*/
★Variable: variables are containers for data.
full_Name= “Sabbir”
age= 15
Rules for declaring variable :
● Variable variables are case sensitive ; ‘a’ &. ‘A’ is different .
● Only letter,digits, underscore(_) and $ is allowed .
● digits cannot be the first letter.
● Reserved word cannot be a variable.
To define variable:
1.var: can be redeclared and updated.
2.let: cannot be redeclared but can be updated.
3.const: cannot be redeclared and updated.
Redeclared:
var a = “ name”
var a= “ full name”
console.log(a)
=>full name
updated:
var a= “name”
a=”full name”
console.log(a)
=>full name
★Datatypes:
1.Primitive Data types:
● number
● string
● boolean
● undefined
● null
● biglnt
● symbol
Object: collection of data.
const or let student= {
fullname: “Sabbir” ;
age: “18” ;
cgpa: “3.6” ;
Ispass: “true” ;
}
console.log(student [“Ispass”])
Or console.log(student.Ispass)
=>true
student[“age”] =student[“age”] +25
console.log(student[“age”])
=>43
★Operator:
1.Arithmetic Operator:
+,-,*,/,%,**
2.Unary Operator:
++(increament),--(decreament)
Post:
let a= 5 ;
Console.log(“a=”++a);
=>a=6
Pre:
let a=5;
console.log(“a=”a++);
=>a=5
console.log(“a=”a)
=>a=6
3.Assignment Operator:
= , += , -= ,*= ,%= , **=
4.comparison Operator:
● Equal to : ==. also type: ===
● Not Equal to : !=. also type: !==
● Getter than : >
● Getter than equal to : >=
● Not getter than: <
● Not getter than equal to: <=
let a= 6;
let b=6;
console.log(“a===b:”a===b);
=> a===b: true
console.log(“a!==b:”a!==b);
=>a!==b:false
5.Logical Operator:
● Logical And : &&
● Logical OR : ||
● Logical Not : !
let a=6;
let b=7;
console.log( a!=b && a<b);
=>true
let a=6;
let b=7:
console.log(!(a>b));
=>true
6.Turnary Operator :
★Conditional statement:
● If statement:
let age= 19;
If(age>18){
console.log(“you can vote”);
}
=>you can vote
let mode= “dark”
let color;
If (mode== “ dark”){
color= “ black”;
}
console.log(color)
=>black
● If-else statement :