Bhai, I was trying to learn this from different sites bit was not able to understand. But aapne kya samjhaaya hai🔥. Love you bhai, aapka data science ka bhi playlist mast hai. All the best bhai ❤️.
//Harry bhi ka promise function pratikpromise(){ return new Promise(function(resolve, reject){ setTimeout(()=>{ let error = false; if(!error){ console.log("Harry bhai ka video dekha samaj me aa chuka hai as per the promise of harry bhai"); resolve(); } else{ console.log("Harry bhai ka video phir se dekh le samaj aa jayega"); reject(); } }, 1000) }); } pratikpromise().then( function() { console.log("Thank you So much Harry Bhai"); }).catch(function() { console.log("Sorry Harry bhai, lekin koshis karuga samaj ne ki") });
function myFun(num1,num2){ return new Promise(function(resolve,reject){ if((num1+num2) >50){ resolve(); }else{ reject(); } }); } myFun(70,30).then(function(){console.log("Number Is Greater then 50 ")}).catch(function(err){console.log("Number is less then 50")});
sorry to be so offtopic but does anyone know of a method to log back into an Instagram account..? I somehow lost my password. I would love any help you can give me
@Iker Oliver I really appreciate your reply. I found the site thru google and im waiting for the hacking stuff atm. Looks like it's gonna take a while so I will reply here later with my results.
Harry bhai dsa k lectures b jaldi upload kijiye... Hm logo k interviews ka time aa gya hai. Or apke lectures se bahot help milti hai.. thank you so much for giving all these contents
Behtareen hogaya bhai... harry Bhai aap se Dil lagi hogai he yaar....💞💕❣️💌❤️💝💟💓💗💖 Ab aapke saaray coarses bhi dekhne ka iraada ban Gaya he... Love you 😘😘😘 From Pakistan ❣️
thanks harry for such a brilliant and simple explaination. here is my practise let p1=new Promise((resolve,reject)=>{ let input=prompt("enter a number"); if(input%2==0){ console.log("even number"); resolve("Hurray"); } else{ console.log("odd number"); reject("oh no!"); } }); p1.then((msg)=>{console.log(msg); return new Promise((resolve,reject)=>{ let name=prompt("enter your name"); if(name=="nitin"){ resolve(); } else{ reject(); } }) }).then(console.log("Nitin found. balle balle!")).catch((err)=>console.log("Promise rejected!",err));
Thanks Harry bhai! Your Quiz solution is here: function dish(){ return new Promise(function(resolve, reject){ setTimeout(() => { const error = false; if(!error) { console.log("Yes!promise is resolved"); resolve(); } else { console.log("No!promise is not resolved"); } }, 4000); }) } dish().then(function(){ console.log("Dish was tasty"); }).catch(function(){ console.log("Dish was insipid"); });
Can any one explain me or give me code how to use setTimeout in promise? Is it necessary to define function in promise only can we not give only name of function there and define it at any other place.
//Can anyone tell me how to wrap it with setTimeout function console.log('Now you are online.'); function callingfun() { return new Promise(function (resolve, reject) { let xhr = new XMLHttpRequest(); xhr.open('GET', 'kk1.txt', true); xhr.onload = function () { if (this.status === 200) { console.log(this.responseText); resolve(); } else { console.log('some error occured'); reject(); } } xhr.send(); }) } callingfun().then(function () { console.log('promise resolved'); }).catch(function () { console.log('promise rejected') });
@@av1shek_ps I think there's no point in using setTimeout function over here, I mean, what you are doing is sending a get request and checking the status of the response, there's not time involved right? If u want you can add it, but here it seems to be illogical
mein just abhi brad traversy ka lecture attend kiya tha udemy se, Promises ka. Difference itna hai apne us lecture ko hindi mein explain kr diya. But mughe ab smgh agya
Sir maine kahi jyada jagahon se promises sikhne ki koshish ki par samajh nahi aaya par aapki video dekhke pehli bar mein hi samajh aa gya. You the best programmer on youtube! One request : pls make a tutorial on sql also please :)
I initially watches your promises on ultimate javascript course very confusing there here clearring explained my suggestion kindly upload this in that playlist
console.log('Promise Quiz') function promise(){ return new Promise(function(resolve, reject){ let understood = true; if(understood){ resolve(); } else{ reject(); } }); } promise().then(()=>{ console.log('Thankyou harry bhai sab samjh me aagya'); }).catch(()=>{ console.log('Samjh ni aya') })
function sum(a,b){ return new Promise (function(resolve, reject){ let c = a+b; if (c >100){ console.log("Sum of A and B is : ",c) resolve("sum is greater than 100") } else{ console.log("Sum of A and B is : ",c) reject("sum is less than 100") } }) } sum(10,23).then(function(a){ console.log(a); }).catch(function(b){ console.log(b) })
@codewithharry please explain the Promise constructor. Isn't it supposed to make a object, which should look like this {...} when we do console.log(func1())
Yes, Promise will create a new object. Harry just chained more stuff to it and probably displayed it (I don't remember the timestamp). I wrote very simple code to make myself understand, it might help. ///////My Code//////////// let oath_keeper = 0; const promiss = new Promise(function(accept, excuse){ if(oath_keeper === 1){ accept("Oath Kept"); } else{ excuse("Oath Broken"); } }); promiss.then(function(message){ console.log(`Message from Promiser: ${message}`); }).catch(function(message){ console.log(`Message from Promiser: ${message}`);; });
// If you know Python, this concept is similar to Try and Except. // Here is simple example of Promises function oddEven(number) { return new Promise(function (resolve, reject) { if (number%2==0) { resolve(); } else { reject(); } }) } oddEven(16).then(function () { console.log("Your number is Even") }).catch(function () { console.log("Your Number is Odd"); })
// Promise To Resolve if the given time is less than 2 sec or it will Reject. function delay(time) { return new Promise((resolve , reject) => { if (time resolve( "Resolve : " + "Time is less or equal to 2 sec"), time) } else { reject("Reject : " +"Time is more than 2 sec") } }) } delay(2000) .then((res) => console.log(res)) .catch((err) => console.log(err))
Please harry kya ap ye 4 concept ko milake ek website banana sikha sakte ho please please please🙏 - Generator - Promises - AJAX Request - - Callback Function
function f2(){ return new Promise((resolve,reject)=> { setTimeout(() =>{ let flag=true; if(flag==true){resolve();} else{reject();} }, 2000}; }); } f2.then(()=>{console.log("no error from API");}).catch(()=>{console.log("error");})
Bhai, I was trying to learn this from different sites bit was not able to understand. But aapne kya samjhaaya hai🔥. Love you bhai, aapka data science ka bhi playlist mast hai. All the best bhai ❤️.
small try:
function checkpwd(pass) {
return new Promise((resolve, reject) => {
setTimeout(() => {
const defaultPass = "admin";
defaultPass == pass ? resolve() : reject();
}, 1000);
});
}
let passEntered = "harry";
checkpwd(passEntered)
.then(() => {
console.log("Password matched");
})
.catch(() => {
console.log("Access Denied");
});
o bhai wah mashAllah. good
Bhai function define nhi kiya promise ma
Promise.then(console.log('harry bhai explained and fulfiled the promise').catch(console.log('ye kabhi print hi nhi hoga')
i tried oddEven exercise with promise:
console.log('tut38(quiz)');
function oddEven() {
return new Promise(function (resolve, reject) {
setTimeout(function () {
let n = 45;
if (n % 2 == 0) {
console.log('number is even');
resolve();
}
else {
console.log('number is odd');
reject();
}
}, 5000);
})
}
oddEven().then(function () {
console.log("Task resolved");
}).catch(function () {
console.log("Oops!!Task rejected");
})
jan aap nay bht piyara function banaya ha
Very good 😊🙌
but we can do same thing by using simple function so whats the difference question
I stumbled upon this video while searching for tutorials on promises, I had been so confused all this time. This worked for me! Thank you Bhai!
Watching right after a year. Wish I had found it before. Thanks Harry bhai.
Very useful to understand this during my internship phase thank you!!!!!!
Hi can you help me with what questions you faced during your js interview ?
//Harry bhi ka promise
function pratikpromise(){
return new Promise(function(resolve, reject){
setTimeout(()=>{
let error = false;
if(!error){
console.log("Harry bhai ka video dekha samaj me aa chuka hai as per the promise of harry bhai");
resolve();
}
else{
console.log("Harry bhai ka video phir se dekh le samaj aa jayega");
reject();
}
}, 1000)
});
}
pratikpromise().then(
function()
{
console.log("Thank you So much Harry Bhai");
}).catch(function()
{
console.log("Sorry Harry bhai, lekin koshis karuga samaj ne ki")
});
function myFun(num1,num2){
return new Promise(function(resolve,reject){
if((num1+num2) >50){
resolve();
}else{
reject();
}
});
}
myFun(70,30).then(function(){console.log("Number Is Greater then 50 ")}).catch(function(err){console.log("Number is less then 50")});
sorry to be so offtopic but does anyone know of a method to log back into an Instagram account..?
I somehow lost my password. I would love any help you can give me
@Andres Sergio instablaster ;)
@Iker Oliver I really appreciate your reply. I found the site thru google and im waiting for the hacking stuff atm.
Looks like it's gonna take a while so I will reply here later with my results.
@Iker Oliver It did the trick and I actually got access to my account again. Im so happy!
Thanks so much you saved my ass!
@Andres Sergio you are welcome xD
Harry bhai dsa k lectures b jaldi upload kijiye... Hm logo k interviews ka time aa gya hai. Or apke lectures se bahot help milti hai.. thank you so much for giving all these contents
var marks=prompt("enter marks");
function papaPromise(){
return new Promise(function(resolve,reject){
score = parseInt(marks);
if (score
Sir, You are best RUclips programmer.
Please, Make tutorial on OpenCV for python. I want to apply OpenCV in Machine Learning.
Behtareen hogaya bhai... harry Bhai aap se Dil lagi hogai he yaar....💞💕❣️💌❤️💝💟💓💗💖
Ab aapke saaray coarses bhi dekhne ka iraada ban Gaya he...
Love you 😘😘😘
From Pakistan ❣️
thanks harry for such a brilliant and simple explaination. here is my practise
let p1=new Promise((resolve,reject)=>{
let input=prompt("enter a number");
if(input%2==0){
console.log("even number");
resolve("Hurray");
}
else{
console.log("odd number");
reject("oh no!");
}
});
p1.then((msg)=>{console.log(msg);
return new Promise((resolve,reject)=>{
let name=prompt("enter your name");
if(name=="nitin"){
resolve();
}
else{
reject();
}
})
}).then(console.log("Nitin found. balle balle!")).catch((err)=>console.log("Promise rejected!",err));
You resolved your promise. Great explanation ! Loved it ♥️
D:sg
Pppppp
true
I think I searched all sites, books but not got the concepts this much clear . Thank you very much Bhai. please make a series on react and node too
Thanks Harry bhai!
Your Quiz solution is here:
function dish(){
return new Promise(function(resolve, reject){
setTimeout(() => {
const error = false;
if(!error)
{
console.log("Yes!promise is resolved");
resolve();
}
else
{
console.log("No!promise is not resolved");
}
}, 4000);
})
}
dish().then(function(){
console.log("Dish was tasty");
}).catch(function(){
console.log("Dish was insipid");
});
U haven't put reject() then what's the point of putting .catch() function .It won't be called .
Learning my entire engineering from here. Thank you.
Finally Today I have understand Promises, Thanks Bro
Can any one explain me or give me code how to use setTimeout in promise?
Is it necessary to define function in promise only can we not give only name of function there and define it at any other place.
Bro if you know can you explain me
//Can anyone tell me how to wrap it with setTimeout function
console.log('Now you are online.');
function callingfun() {
return new Promise(function (resolve, reject) {
let xhr = new XMLHttpRequest();
xhr.open('GET', 'kk1.txt', true);
xhr.onload = function () {
if (this.status === 200) {
console.log(this.responseText);
resolve();
}
else {
console.log('some error occured');
reject();
}
}
xhr.send();
})
}
callingfun().then(function () { console.log('promise resolved'); }).catch(function () { console.log('promise rejected') });
@@av1shek_ps I think there's no point in using setTimeout function over here, I mean, what you are doing is sending a get request and checking the status of the response, there's not time involved right?
If u want you can add it, but here it seems to be illogical
Just wrap everything starting from initialisation of XML object to the end inside the setTimeout function
Harry bhai...apne promise pura kiya...samaj aa gaya promise😄❤️
Bro great explaining, hats off to your efforts
Love from Pakistan Karachi❤️
I'm also
@@muhammadyousufjaseem4084 Same
Best Expalanation ever in the most layman language.
function number(n1, n2) {
return new Promise((resolve, reject) => {
if (n1 >= 0 || n2 >= 0) {
console.log("Function: your promise has been resolved");
resolve(n1 + n2);
} else {
console.log("Function:your promise has not been resolved");
reject("sorry not fullfilled ");
}
});
}
number(10, -20)
.then((result) => {
console.log("prajwal:Thanks for resolving " + result);
})
.catch((error) => {
console.log("prajwal:very bad" + error);
});
great explanation thanks harry bhaii❤❤
promise resolved() with Love from Pakistan Lahore Punjab ❤️
harry bhai aapne apna best promise video ko successfully resolve kar liya. Thank you so much...:)
Amazing explanation!!!❤️❤️❤️
it's really very useful thanks a lot
Understood in one go. Patte se headshot Harry bhai!!!
starting mai laga tha ki nahi aayega samajh mai, par 1 dum badiya se samajh aagaya
waah kya explanation so easy to understand to learn a complex thing. Salute🤘🙏🙏🙏
mein just abhi brad traversy ka lecture attend kiya tha udemy se, Promises ka. Difference itna hai apne us lecture ko hindi mein explain kr diya. But mughe ab smgh agya
Harry bro as always you resolved your promise LOVED YOUR EXPLANATION🤩🥰
Good one bro. Bohot ache se samjhaya bhai ne! Keep up the good work
Sir maine kahi jyada jagahon se promises sikhne ki koshish ki par samajh nahi aaya par aapki video dekhke pehli bar mein hi samajh aa gya. You the best programmer on youtube! One request : pls make a tutorial on sql also please :)
okkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkl.
Sir materialize css ki series banavo please
promise resolved!! well explained!!👍
Best In The World (ABOVE ALL) THANKS bro
harry bhai ...bht jagh se try kra kia but atlast yha jake samjh aaya thnxxx bhaii!!!!!
3M Soon Harry Bhai
big congratulations in advance 🎉❤
Thanks for resolving your promise ♥️🙏💯
I initially watches your promises on ultimate javascript course very confusing there here clearring explained my suggestion kindly upload this in that playlist
mast hai bhai maja aa gaya
Promise Resolved Thanks Harry ❤
Thanks a lot bro. You explained it very well.
Sir ke fan like thoko👈👌🤙
Big fan
You are amazing brother. God bless you
console.log('Promise Quiz')
function promise(){
return new Promise(function(resolve, reject){
let understood = true;
if(understood){
resolve();
}
else{
reject();
}
});
}
promise().then(()=>{
console.log('Thankyou harry bhai sab samjh me aagya');
}).catch(()=>{
console.log('Samjh ni aya')
})
thank you bhai ...........u r d best youtube programmer ever................
great content
I think my iitkkgp profs will also not teach me like this. Loved the way you used examples.
Thank you harry bhai. You are god.
The way you are explaining is really good.
you nailed it. and yes it is a resolve.
you save my life brother..🙌awesome
bhi muzy tu maza a agya phr na ma mara pura samj ma a gaya thank you bhi
I have watch this video 4 time now finally i'm understand 😍
after buying the Coding ninja web dev course, come here to catch on, easy to understand video loved it ❤️
apne course liya tha kiya?
@@webcreationstudio7088 yes
Bhaiya please make video on Android Development .
Best Video for learning Javascript.
Thank you harry bhai
function sum(a,b){
return new Promise (function(resolve, reject){
let c = a+b;
if (c >100){
console.log("Sum of A and B is : ",c)
resolve("sum is greater than 100")
}
else{
console.log("Sum of A and B is : ",c)
reject("sum is less than 100")
}
})
}
sum(10,23).then(function(a){
console.log(a);
}).catch(function(b){
console.log(b)
})
How should I thank you Harry bhai, you are the best..
Hi.
Your tutorial is informative.
I loved it.
Thanks for sharing and keep the good work going
You are an amazing guy... keep it up
@codewithharry please explain the Promise constructor. Isn't it supposed to make a object, which should look like this {...} when we do console.log(func1())
Yes, Promise will create a new object. Harry just chained more stuff to it and probably displayed it (I don't remember the timestamp). I wrote very simple code to make myself understand, it might help.
///////My Code////////////
let oath_keeper = 0;
const promiss = new Promise(function(accept, excuse){
if(oath_keeper === 1){
accept("Oath Kept");
}
else{
excuse("Oath Broken");
}
});
promiss.then(function(message){
console.log(`Message from Promiser: ${message}`);
}).catch(function(message){
console.log(`Message from Promiser: ${message}`);;
});
17:36 explanation
Your promise resolved Thanks
// If you know Python, this concept is similar to Try and Except.
// Here is simple example of Promises
function oddEven(number) {
return new Promise(function (resolve, reject) {
if (number%2==0) {
resolve();
} else {
reject();
}
})
}
oddEven(16).then(function () {
console.log("Your number is Even")
}).catch(function () {
console.log("Your Number is Odd");
})
promise done perfect harry bhai ...
Bohut acha explain kiya bhai ap ney
Harry bhai you really resolved your promise❤😉
Famous club concept if (age
ur comment helped me to know the difference
thnks
congratulation for 2million hary bhai
thanks
Fantastic
Awesomeeeee bro dhang se samhjha diya tune
Much Much Appreciated Harry Bhai...
Bahat try kiya samajne k liye but humko samaj nahi aha raha ha ki ye promise use q kare?
Sabashhhh!!!!! bhahut badiya samjaya apne..
sir we are always see you full vidio
thanks bro i was so confused about this and you helped me a lot .
Very nicely explained Harry bhai !!
Thank you bhai ❤️
superb brother
// Promise To Resolve if the given time is less than 2 sec or it will Reject.
function delay(time) {
return new Promise((resolve , reject) => {
if (time resolve( "Resolve : " + "Time is less or equal to 2 sec"), time)
}
else {
reject("Reject : " +"Time is more than 2 sec")
}
})
}
delay(2000)
.then((res) => console.log(res))
.catch((err) => console.log(err))
Harry bhai i like your django tutorials.. love you vai
bhai gajab padhate hoo app maja agaya :*
Please harry kya ap ye 4 concept ko milake ek website banana sikha sakte ho please please please🙏
- Generator
- Promises
- AJAX Request -
- Callback Function
function deleteStudent(index){
console.log("indise delete",student)
return new Promise(function(resolve,reject){
student.splice(index,1)
const error = true;
if (error) {
resolve();
}
else {
reject();
}
});
}
deleteStudent(0).then(success).catch(failure);
function success(){
console.log("Successfully Delete" , student)
}
function failure(){
console.log("Something went wrong", student)
}
Harry Bhai you resolved your promise 🙏 ❤️👍
so bhaiya callbacks and promises are used to synchronize JS
Promise is resolved by Harry Sir
function isDay(hours){
return new Promise(yes, no){
if(hours>5 && hours
I am always ready for your video
Like too banta hai
Your videos are very good sir.Appreciate your youtube work.
Please make a video on AJAX
I have already uploaded a video no Ajax with title "Ajax tutorial in hindi"
Kindly access the playlist!
@@CodeWithHarry harry bahii bilkul right
Mai aap logo se promise karta hu ke
mai aap logo to *promise* acche tarike se batunga
What a way to teach 😂😍
Super Dost... very well explained
superb video
function f2(){
return new Promise((resolve,reject)=> {
setTimeout(() =>{
let flag=true;
if(flag==true){resolve();}
else{reject();}
}, 2000};
});
}
f2.then(()=>{console.log("no error from API");}).catch(()=>{console.log("error");})
Please make video on Pyodide
Harry bhai apne promise pura kardia!