Inp Code
Inp Code
Xml
2. Xml dom
3. useState
4. useEffect
5. How to install and uninstall different modules using npm?
else
if (hour < 18) {
greeting = "Good day";
} else {
greeting = "Good evening";
}
Else if
if (time < 10) {
greeting = "Good morning";
} else if (time < 20) {
greeting = "Good day";
} else {
greeting = "Good evening";
}
3. Switch
switch (new Date().getDay()) {
case 0:
day = "Sunday";
break;
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
case 6:
day = "Saturday";
}
4. Default
b. For in
const person = {fname:"John", lname:"Doe", age:25};
c. For of
const cars = ["BMW", "Volvo", "Mini"];
A. While
while (i < 10) {
text += "The number is " + i;
i++;
B. Do While
do {
text += "The number is " + i;
i++;
}
while (i < 10);
6. Generator ::
function* gen1(){
yield 200,
yield;
yield 300;
}
Var mygen=gen1();
console.log(mygen.nest().value);
console.log(mygen.nest().value);
console.log(mygen.nest().value);
7. Arrow ::
Var myfun=function display(){
console.log(“function expression”);
}
Var myfun1=function(){
console.log(“anonymous expression”);
}
Var myfun2=()=>{
console.log(“arrow expression”);
}
8. Promise ::
promise.all([
new promise(resolve=>setTimeout(()=>resolve(1),3000))
new promise(resolve=>setTimeout(()=>resolve(2),2000))
]).then(alert)
9. Npm installation
https:/nodejs.org/en/download
# Yarn
yarn add redux
B
Var http=require(“http”);
Const data = fs.readFileSync(“”mongo.js”);
console.log(data);
console.log(“hello world”);
//<buffer>
//hello world
fs.readFile(filename,[option],callback)
21. Callbacks
Function createQuote(quote,callback){
Var myquote=”my name’+quote;
callback(myquote);
}
Function logquote(quote){
console.log(quote);
}
createQuote(“muzammil”,logquote)
23. Lifecycle
1.initial phase
getDefaultProps()
getInitialStates()
2. Mounting phase
componentWillMount()
componentDidMount()
render()
3. Updating phase(optional)
componentWillReceiveProps()
shouldComponentUpdate()
componentWillUpdate()
render()
componentDidUpdate()
4. Unmounting
componentWillUnmount()
Steam
Const fs=require(‘fs’);
Const file=fs.createWriteStream(“file.txt”);
for (let i=0; i<100; i++){
fileWrite(“hello world”);
}
file.end()