Professional Documents
Culture Documents
8-4-2024-11am
8-4-2024-11am
8-4-2024-11am
https://chat.whatsapp.com/J7NF0yj1OWD59WgPJ9hHC2
=========================================
loggedIn
Scrum
1. What is variable ?
var name="sachin"
name="sachin"
2. What is function ?
3. What is callback ?
6. programs
1. function fn(){
console.log(a);
}
fn()
-error - a is not defined
2.
function fn(){
var a=10;
}
console.log(a)
-error - a is not defined
3.
function fn(){
var a=10;
}
fn()
console.log(a)
-error - a is not defined
4.
function fn(){
let a=10;
}
fn()
console.log(a)
-error - a is not defined
5.
function fn(){
const a=10;
}
fn()
console.log(a)
-error - a is not defined
6.
function fn(){
a=10;
}
fn()
console.log(a)
-10
7.
var a=10
function fn(){
console.log(a)
}
fn()
console.log(a)
10
10
8. function fn(a,b){
console.log(a+b)
}
fn()
NaN
9. function fn(){
console.log(a+b)
}
fn()
error- a is not defined
10.
function fn(a+b){
console.log(a+b)
}
var result =fn(10,20)
result ?
undefined
11.
function fn(a+b){
return a+b
}
var result =fn(10,20)
result ?
30
a is not a function
13.
function fn(a){
a()
}
fn(10)
a is not a function
14.
function fn(a){
a()
}
function f1(){
fn(f1)
f1 - callback
fn - Higher Order function
15.
function fn(a){
return a;
}
function f1(){
return 10;
}
16.
function fn(){
function f1(){
return 10;
}
return f1
}
var result=fn()
result()
10
17. How many ways you can call the anonymous functions ?
a. immediate invoking
b. assing to one varibale
c. pass as a callback
18.
function fn(a,b){
a("sachin");
b();
return function(){
console.log("kohli");
}
}
fn(
function(data){
console.log(data)
},
function(){
console.log("dhoni")
}
)()
26-03-2024
Dat 6:
document, window, getReference, events, eventbubbling, eventCapturing
Programs
Interview Questions
Assignment - JS program -2(write/todo)
Notes -
Write HTML, CSS, Bootstrap,JavaScript Test
What is document ?
What is window ?
getElementById
getElementsByTagName
getElemebtsByClassName
getElementsByName
querySelector
querySelectorAll
#header2 > div > div > div > div > div.topnav_cont > a:nth-child(2)
<div id="header2">
<div>
<div>
<div>
<div>
<div class="topnav_cont">
<a>
<a>
</div>
<div>
</div>
</div>
</div>
</div>
</div>
Day 7
setTimeout, setInterval, clearTimeout, clearInterval,Debouncing, Throttling
Programs
Interview Questions
Assignment - JS program -3(write/todo)
Notes -
Write HTML, CSS, Bootstrap,JavaScript Test
console.log(1)
console.log(2)
console.log(3)
1
2
3
setTimeout
type - function
argument- 3 - handleer , time , ...
return type - number
clearTimeout
type - function
arg- one - number
function fn(a,b,c,d){
}
fn(10,20)
setInterval
type - function
argument- 3 - handleer , time , ...
return type - number
clearInterval
type - function
arg- one - number
var count=10;
var inervalId=setInterval(function(){
count=count-1
gmailRef.innerHTML=count
if(count==0){
clearInterval(inervalId);
alert("timeup...")
}
},1000)
Debouncing....
1. What is class ?
2. What is Object ?
3. What is constructor ?
4. What is this ?
5. What is inheritance ?
6. What is abstraction ?
7. What is polymorphism ?
8. What is encapslation?
9. What is overloading ?
10.What is overriding ?
11. class properties ?
12. static keyword ?
13. type of inheritance ?
17.What is prototype in JS ?
function Arth(){
this.n1=10;
this.n2=20;
this.sum=fucntion(){
console.log(this.n1+this.n2)
}
}
var obj=new Arth();
obj.n1//10
obj.n2//20
obj.sum()//30
obj["n1"] //10
ob["sum"]()//30
=================================
function Arth(){
this.n2=20;
this.sum=fucntion(){
console.log(this.n1+this.n2)
}
}
var obj=new Arth();
obj.n1 // undefined
obj.n2//20
obj.sum() // NaN
How to fix ?
Arth.prototype.n1=10;
obj.sum() //30
========================
function Arth(){
this.n1=10;
this.n2=20;
this.sum=fucntion(){
console.log(this.n1+this.n2)
}
}
var obj=new Arth();
obj.sub()
//obj.sub is not a funciton
How to fix ?
Arth.prototype.sub=function(){
console.log(this.n1-this.n2)
}
=================================
function A(){
this.n1=10
}
function Arth(){
this.n2=20;
this.sum=fucntion(){
console.log(this.n1+this.n2)
}
}
how to fix ?
Arth.prototype=new A();
obj.sum() // 30
---------------------------------
29-03-2024
1. What is class ?
2. What is Object ?
3. What is constructor ?
4. What is this ?
5. What is inheritance ?
10.What is overriding ?
17.What is prototype in JS ?
function Arth(){
this.n1=10;
this.n2=20;
this.sum=fucntion(){
console.log(this.n1+this.n2)
}
}
var obj=new Arth();
obj.n1//10
obj.n2//20
obj.sum()//30
obj["n1"] //10
ob["sum"]()//30
=================================
function Arth(){
this.n2=20;
this.sum=fucntion(){
console.log(this.n1+this.n2)
}
}
var obj=new Arth();
obj.n1 // undefined
obj.n2//20
obj.sum() // NaN
How to fix ?
Arth.prototype.n1=10;
obj.sum() //30
========================
function Arth(){
this.n1=10;
this.n2=20;
this.sum=fucntion(){
console.log(this.n1+this.n2)
}
}
var obj=new Arth();
obj.sub()
//obj.sub is not a funciton
How to fix ?
Arth.prototype.sub=function(){
console.log(this.n1-this.n2)
}
=================================
function A(){
this.n1=10
}
function Arth(){
this.n2=20;
this.sum=fucntion(){
console.log(this.n1+this.n2)
}
}
how to fix ?
Arth.prototype=new A();
obj.sum() // 30
---------------------------------
class Arth{
var n1=10
} syntax error
================
class Arth{
n1=10;
n2=20;
sum(){
console.log(this.n1+this.n2)
}
}
obj["sum"]() // 30
obj.sum() // 30
=======================
class Arth{
n1=10;
sum(){
console.log(this.n1+this.n2)
}
}
NaN
Arth.prototype.n2=20
obj.sum()//30
obj.sub // undefined
obj.sub()// obj.sum is not a function
=======================
class A{
n1=10;
}
class B extends A{
n2=20;
sum(){
console.log(this.n1+this.n2)
}
}
function A(){
this.n1=10;
}
class B extends A{
n2=20;
sum(){
console.log(this.n1+this.n2)
}
}
Note:
B should be class keyword class
A can be class / function keyword class
==================================
class A{}
class B extends A{}
A - Parent/Super/Base
B - Child/sub/Derived
Single
class A{}
class B extends A{}
Multiple
class A{}
class B{}
class C extends A,B{}
Multilevel
class A{}
class B extends A{}
class C extends B{}
Overloading
function sum(a,b,c){
console.log(a+b+c)
}
function sum(a,b){
console.log(a+b)
}
function sum(a){
console.log(a)
}
sum(1,2,3) // 6
sum(1,2) // 3
sum(1) //1
class Arth{
sum(a,b,c){
console.log(a+b+c)
}
sum(a,b){
console.log(a+b)
}
sum(a){
console.log(a)
}
}
Overriding
alert("nit")
function alert(msg){
// writted code create popup - 100
// place msg inside the popup
// show the popup
/ /place ok button
}
function alert(msg) {
console.log(msg)
}
class Parent{
property(){
console.log("1cr")
}
}
class Child extends Parent{
property(){
console.log("0cr")
}
}
==================================
class A{
constructor(){
console.log("f1");
}
}
var obj=new A()
f1
==========
class Parent{
constructor(){
console.log("Parent");
}
}
class Child extends Parent{
1. extended child class default constructor, they check for parent , if there parenet there
call parent class constrctor
==================================
abstraction
encapslation
==============================
interface vehicle{
createFlyVehicle();
changeColor();
}
class v{
createFlyVehicle(){
----
=====
}
changeColor(){
}
}
30-03-2024
Array methods
Programs
Interview Questions
Assignment - JS program -13(write/todo)
Notes -
Write HTML, CSS, Bootstrap,JavaScript Test
const players=["Sachin","Dhoni","kohli"]
players.length
obj.name
==============================
var obj={
name:"Sachin"
}
obj.name
//Sachin
another fix
class A{
name="sachin"
}
var obj=new A()
obj.name
//Sachin
==================
var arr=[1,2,3]
arr.push(4)
useCase-
====================
var arr=[1,2,3,4]
arr.pop()
useCase-
==========================
var arr=[1,2,3,4]
arr.indexOf(3) 2
arr.indexOf(2) 1
arr.indexOf(5) -1
arr.indexOf(2,3) -1
arr.indexOf(3,2) 2
useCase-
===================================
var arr=[1,2,3,4]
arr.inclues(3) - true
arr.inclues(2) - true
arr.inclues(5) - false
arr.inclues(2,3) -false
arr.inclues(3,2) -true
useCase-
===================================
var arr=[1,2,3]
arr.unshift(4)
type- inherited method inside Array class
args- rest parameter(0 to any)
return type- number
return value- new array length
useCase-
====================
var arr=[1,2,3,4]
arr.shift()
useCase-
=====================
var arr=[1,2,353,343,5,56]
arr.slice() [1,2,353,343,5,56]
arr.slice(3) [343,5,56]
arr.slice(3,5) [343,5]
arr.slice(5,3) []
useCase- pagination
---------------------------------
var arr=[1,2,353,343,5,56]
arr.splice(2,1)
return [353]
arr - [1,2,343,5,56]
arr.splice(3,2,33,44)
return [5,56]
arr - [1,2,343,33,44]
===========================================
var arr=[1,2,3,4]
arr.forEach
useCase -
04-04-2024
2. What is an exception ?
10. R u sure, all the statements inside catch block will execute ?
11. R u sure, all the statements inside finally block will execute ?
12. Write a code snippet , How you hanlde runtime erros in your application ?
Promises,callbacks
Programs
Interview Questions
Assignment - JS program -9(write/todo)
Notes -
Write HTML, CSS, Bootstrap,JavaScript Test
callbacks:
Shop:
function printCards(no,text,scb,ecb){
console.log("start printing the cards");
console.log("action going on...");
const isPrinted=true
if(isPrinted){
console.log("${no} cards printed")
scb(no)
}else{
console.log(" cards not printed")
ecb(0)
}
}
college:
printCards(
100,
"nit",
function(cards){
console.log("${cards} received");
console.log("distirbute the cards");
console.log("start and end");
},
function(){
}
)
Primsie
functional class
while createing an object, we should have to pass one function as argument
that argument called by constructor by passing 2 arguments
those 2 arguments are function type
Shop:
function printCards(no,text){
2 ways
a. then method
a. method inside Promise class
b. take max 2 parameters
c. 2 parameters types are functions
d. returns Promise object
b. await keyword
a. keyword
b. fallows always promise object
c. returns promise object success result only
d. failure result can handle using try,catch,finally
cosnt promiseObj=printCards(100,"nit")
promiseObj.then(
function(){
console.log("1st called");
},
function(){
console.log("2nd called");
}
)
=================================
obj.then(
function(data){
console.log(data)
},
function(){
}
)
Throttling…
05-04-2024
1. what is asynchronous action ?
11. How to hanlde the success response using then and await ?
then(
function(){},
function(){} // failure
)
or
.then()
.catch(
function(){}// failure
)
or
try{
await promiseObj
}
catch(e){}
====================================
1.
po1.then(
function(data){
console.log(data)
}
)
2.
res //100
=================================
1.
po1.then(
function(data){
console.log(data)
},
function(data){
console.log(data);
}
)
2.
po1.then()
.catch(function(data){
console.log(data)
})
3.
try{
const res=await po1
}catch(e){
console.log(e)
}
=====================================
1.
f1().then(
function(data){
console.log(data)
}
)
2.
res //100
================================
1. Promise.resolve(100)
3. new Promise(function(resolve,reject){
resolve(100)
})
======================
Promise {<rejected>: 100}
Promise.reject(100)
new Promise(function(resolve,reject){
reject(100)
})
=================================
Promise.resolve
Promise.reject
Promise.all
Proimse.allSettled
Promsie.any
Promsie.race
Promise.withResolvers
let { promise, resolve, reject } = Promise.withResolvers();
-----------------------------
po1.then(function(){},function(){})
po1.then(function(){}).catch(function(){})
await po1
oo.subscribe(function(){},function(){})
06-04-2024
document.cookie="name=sachin" - inmemory
document.cookie="loc=Mumabi;expires=---"
document.cookie="loc=Mumabi;expires=yesterday"
document.cookie=""
===============================
https://www.youtube.com/watch?v=CjWJ_8u-nDs&list=PLi0B7bAUSoVtX3IrC09hsZKEorc-
bOW15&index=23
https://www.youtube.com/watch?v=wioAeuUDS1Y&list=PLi0B7bAUSoVtX3IrC09hsZKEorc-
bOW15&index=49
equals(obj1,obj2)