What is JavaScript
JavaScript is a high level programming Interpreted language.it is allow for developer add button animation website etc. This is run in the browser
Work with the JavaScript
1. CSS
2. HTML
3. JavaScript (logic and behaviour)
History of Javascript
. Create by Brendan Eich in 1995
. Develope at the Netscape
. Initially Name Mocha later live script finally Javascript
Why Javascript Important
. It is used frontend and the backend development
. The high job of freelancing
JavaScript in The Variables
it is used for the data store
Var
var name="Ram"
Let
let age = 20;
Const
const city= "Delhi"
Use let and const
Types of Data Primitive
.String
.Number
.Boolean
.Undefined
.Null
Symbol
.Biglnt
Examples;
let name="Aman"; //String
let marks= 80; //Number
let isPass= true; //Boolean
Operators in JavaScript
.Arithmetic: + - * / %
.Logical: && || !
.Assignment: = += -=
.Comparison: == === != > <
Examples;
let x = 45;
let y = 78;
console.log(x + y);
Conditional Statements
if-else
if (score >= 90) {
console.log("Eligible to Won");
}else{
console.log("it is not eligible")
Switch
switch(day) {
case 1;
console.log("Sunday")
break;
}
JavaScript in a loop
for loop
for(let x=3; x<=9; x++{
console.log(x);
}
while loop
let x = 1
while (i <= 8){
console.log(i);
i++;
}
function of JavaScript
its function is the reusable blocks of code.
function multiply(x, y) {
return x * y;
}
console.log(multiply(4, 5));
Arrow Function
const add = (x, y) => x + y;
Array in the JavaScript
Array are store in the multiple values.
let fruits = [ "Litchi", "Orange", "Mango"];
console.log(fruit[0]);
Object in JavaScript
objects are store data for key value of pairs.
let Student = {
fullName: "Kunal Thakur",
marks: 78,
subject: "Chemistry",
};
console.log(student.name);
Array Method of the Common
.push()
.pop()
.shift()
unshift()
.length()
Document Object Model(DOM)
DOM it is allow interact with HTML from JavaScript.
document.getElementById("myId").innerHTML = "Namaste";
Events in JavaScript
HTML of file
<div id="myId">
<button id="choice"> Choice anything</button>
</div>
In JavaScript file
document.getElementById("myId").addEventListener(
"click",
() => console.log("myId clicked"),
false
);

Comments
Post a Comment