js.zonayed.me icon indicating copy to clipboard operation
js.zonayed.me copied to clipboard

নিত্যদিনের জাভাস্ক্রিপ্টঃ ফার্স্ট ক্লাস ফাংশন ও হাইয়ার অর্ডার ফাংশন

Open utterances-bot opened this issue 5 years ago • 2 comments

নিত্যদিনের জাভাস্ক্রিপ্টঃ ফার্স্ট ক্লাস ফাংশন ও হাইয়ার অর্ডার ফাংশন | হাতেকলমে জাভাস্ক্রিপ্ট

একটা শর্টে লেখার অংশবিশেষ

https://js.zonayed.me/daily/post-0

utterances-bot avatar Jan 22 '21 11:01 utterances-bot

function callMyName(name, callback) { var myAge = 20; callback(myAge); console.log('Is it interesting? Yes it is Mr.' + name); }

function hello(age) { console.log('I am passed through argument and my age is: ' + age); }

callMyName('Zonayed Ahmed', hello);

I don't understand this code here callback is a parameter , in the 3rd line you use this parameter as a function . there myAge is also a parameter. well , but in the 2nd part age != myAge so why the output shows 20 ?

abdullaalmaruf avatar Jan 22 '21 11:01 abdullaalmaruf

@abdullaalmaruf as you said above here also, Zonayed Ahmed != name hello != callback this is the way parameter actually works. the first argument connects with the first parameter and second arg. with second parameter also. in the second function, age is a parameter and myAge is a argument respectively. and myAge assigned to 20 also. I think you are all clear. Happy Learning.

sshuvoo avatar Jan 31 '21 12:01 sshuvoo