নিত্যদিনের জাভাস্ক্রিপ্টঃ ফার্স্ট ক্লাস ফাংশন ও হাইয়ার অর্ডার ফাংশন
নিত্যদিনের জাভাস্ক্রিপ্টঃ ফার্স্ট ক্লাস ফাংশন ও হাইয়ার অর্ডার ফাংশন | হাতেকলমে জাভাস্ক্রিপ্ট
একটা শর্টে লেখার অংশবিশেষ
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 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.