Smart Coder

Smart Coder Contact information, map and directions, contact form, opening hours, services, ratings, photos, videos and announcements from Smart Coder, Web designer, Yangon.

Is the parameter the same as the argument?    programming လေ့လာဖူးသူ အားလုံးပဲ (function/method) တခုရဲ့ parameter နဲ့ ar...
12/11/2022

Is the parameter the same as the argument?

programming လေ့လာဖူးသူ အားလုံးပဲ (function/method) တခုရဲ့ parameter နဲ့ argument ကိုသိကြမယ်ထင်ပါတယ်။ Beginner အတော်များများက parameter နဲ့ argument ကိုအတူတူပဲလို့ထင်လေ့ရှိကြပါတယ်။ တကယ်တမ်းကြတော့ မတူပါဘူး ဘာလို့မတူတာလဲလို့ ဆိုရင်
parameter is the kind of variable. တွေဖြစ်ကြပြီး
argument တွေက parameter ထဲကို assignment လုပ်မဲ့ value တွေဖြစ်တာကြောင့်ပဲ ဖြစ်ပါတယ်။

"Parameters are initialized to the values of the arguments supplied." ဆိုပြီး MDN ရဲ့ official website မှာဖော်ပြထားပါတယ်။ အောက်ပါ link မှာဝင်ရောက်ဖတ်ရှုလေ့လာနိုင်ပါတယ်။
shorturl.at/yCKX1

Example Code in javascript from MDN :

function example(parameter) {
console.log(parameter); // Output = foo
}

const argument = "foo";

example(argument);

အထက်ပါ code အရဆိုရင် example ဆိုတဲ့ function ကို invok လုပ်တဲ့အချိန်မှာ "foo" ဆိုတဲ့ data assign လုပ်ထားတဲ့ argument ဆိုတဲ့ variable ကိုထည့်ပေးလိုက်ပါတယ်။ example ဆိုတဲ့ function ကို invok လုပ်လိုက်တဲ့အတွက် ex*****on context တစ်ခုစလုပ်ပါတယ်။ အဲ့ဒီမှာ example function ကို invok လုပ်တုန်းကထည့်ပေးလိုက်တဲ့ "foo" ဆိုတဲ့ argument value ကို parameter ဆိုတဲ့ local memory variable ထဲမှာသွား assign လုပ်ပါတယ်။ ပြီးတော့ console.log(parameter) ဆို run နဲ့အချိန်မှာ "foo" ဆိုတဲ့ data လေးကို console မှာမြင်ရမှာပဲဖြစ်ပါတယ်။

Beginner တွေအတွက်ရည်ရွယ်ပြီးရေးသားခြင်းဖြစ်၍ သိပြီးသားသူများ အတွက်တော့ ပျင်းစရာကောင်းမယ်လို့ထင်ပါတယ်။(sorry about that :p)

နောက်တစ်ခါကြရင်တော့ closure function အကြောင်းကိုပြောပြပေးသွားမှာဖြစ်ပါတယ်ဗျ။ comment section တွင် ဆွေးနွေး၊ အကြံပေး၊ ဝေဖန် ခြင်းများကိုပြုလုပ်နိုင်ပါတယ်ဗျ။

Thank you for reading.
Stay safe guys.

Address

Yangon
11071

Website

Alerts

Be the first to know and let us send you an email when Smart Coder posts news and promotions. Your email address will not be used for any other purpose, and you can unsubscribe at any time.

Share

Category