Bhaiya please aap DSA ki bhi playlist bnao n aap bhot acha pdhate ho 🔥🔥 you are really such a very great teacher bro aur mughe apka pdhaya hua bhot ache se smj aata hh
The answer which i replied in another thread, applies here also You are trying to mix normal function with anonymous function while writing both in a program. Its just matter of how you look at the code, separate your concepts and you are good to go.
disp() function is not an anonymous function. however what it returns is a function without any name, or returns an anonymous function. in case we do not want the return as the whole anonymous function, and we r interested in getting the result of its body, then we r unable to get the result as we cannot call an anonymous function ( with no name). therefore first we have to store it in a variable, say var=af; and then call the anonymous function with the help of function expression . af(20); note 20 is the argument for the anonymous parameter b.
I have the same doubt .. but this is what i understood function trg(f){ return function(g){ return f+g; } } document.write(trg(10)); -------------------- this will return - function(g){ return f+g; }, with f=10. now this returned thing is assigned to a variable.. it became a function expression and we printed the entire function expression with g=20 ..
Also we know that an inner function has access to the parameters (or arguments) of the outer function. Hence the inner anonymous function gets the value of a=10 from disp(10).
Advance Tip: We can also write,
var sum = disp(10)(20);
document.write(sum);
This is known as Function Currying.
Bhaiya please aap DSA ki bhi playlist bnao n aap bhot acha pdhate ho 🔥🔥 you are really such a very great teacher bro aur mughe apka pdhaya hua bhot ache se smj aata hh
You have explained well..and in a systematic way with out huary.. my doughts get cleared
Closure ka perfect example hain.
Sir please make a complete video on regular expressions
Thanks brother :)
thnku thnku thnku......
Thank you
Pls make DSA play list
Wen u hv given disp as the function name..then how can it b anonymous function??
The answer which i replied in another thread, applies here also You are trying to mix normal function with anonymous function while writing both in a program. Its just matter of how you look at the code, separate your concepts and you are good to go.
disp() function is not an anonymous function. however what it returns is a function without any name, or returns an anonymous function.
in case we do not want the return as the whole anonymous function, and we r interested in getting the result of its body, then we r unable to get the result as we cannot call an anonymous function ( with no name). therefore first we have to store it in a variable, say
var=af; and then call the anonymous function with the help of function expression .
af(20); note 20 is the argument for the anonymous parameter b.
8.30 how can af(); function have value of a = 10 variable that is part of disp() function at execution time ?
I have the same doubt .. but this is what i understood
function trg(f){
return function(g){
return f+g;
}
}
document.write(trg(10));
-------------------- this will return - function(g){ return f+g; }, with f=10.
now this returned thing is assigned to a variable.. it became a function expression and we printed the entire function expression with g=20 ..
function(g){ return f+g; }
Also we know that an inner function has access to the parameters (or arguments) of the outer function. Hence the inner anonymous function gets the value of a=10 from disp(10).
It is just simple mistake during writing and speaking . Here a = 10 , and b = 20.
✅✅✅
Thank You Sir
Explained well
var af = (disp(10));
or
var af = disp(10);
what's the diffrence in both.
Both are working fine can you tell me about it thanks..
it's like a value stored in a var i.e. (10) or 10 both are same.
it is optional to use (disp) we can also directly use disp.
Sir insab ka web development se kya lena dena.
Ye question to mera first episode se hai
Mera bhi same question?
Me too
kis chiz ka?
Which book is best for learning js ?
are bhai 👏🏼👏🏼
thanks
Thank u sir.
awesome
what is var af = (); syntax is
Iska istamal hotta hain ya nahi
Hota h