8000 commit · Himanxusharma/JavaScript@97417d7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 97417d7

Browse files
committed
commit
1 parent 03d6d8c commit 97417d7

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

Ajax.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,45 @@
402402
// })
403403

404404

405+
// // promises
406+
// // why promises are used - Promises are used to handle asynchronous operations in JavaScript. They are easy to manage when dealing with multiple asynchronous operations where callbacks can create callback hell leading to unmanageable code.
405407

408+
// // promises produce
409+
// const probj1 = new Promise((resolve,reject)=>{
410+
411+
// setTimeout(()=>{
412+
// let roll = [1,2,3,4,5,6];
413+
// resolve(roll);
414+
// // reject('Error happened');
415+
// },1000);
416+
417+
// });
418+
419+
// const getdata =(indexdata)=>{
420+
// return new Promise((resolve,reject)=>{
421+
// setTimeout((indexdata) => {
422+
// let biodata ={
423+
// name:'Sunny Deol',
424+
// age : 23
425+
426+
// }
427+
// resolve(`My roll no is ${indexdata}. My name is ${biodata.name} and I am ${biodata.age} year old. `)
428+
// }, 1000,indexdata);
429+
// });
430+
// }
431+
432+
// // .. promises consume
433+
// probj1.then((rollno)=>{
434+
// console.log(rollno);
435+
// return getdata(rollno[1])
436+
// }).then((data)=>{
437+
// console.log(data);
438+
// }).catch((error)=>{
439+
// console.log(error);
440+
// })
406441

407442

408443

409-
// // promises
410444

411445
// // async await
412446

0 commit comments

Comments
 (0)
0