JavaScript ကို သတ်မှတ်မထားပါ။
ဥပမာများ
တန်ဖိုးမရှိသော ကိန်းရှင်-
let x;
if (x === "undefined") {
text = "x is undefined";
} else {
text = "x is defined";
}
let x;
if (typeof x === "undefined") {
text = "x is undefined";
} else {
text = "x is defined";
}
အောက်တွင် နောက်ထပ် ဥပမာများ။
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
မသတ်မှတ်ထားသော ပိုင်ဆိုင်မှုသည် ကိန်းရှင်တစ်ခုအား တန်ဖိုးတစ်ခု သတ်မှတ်မပေးခဲ့၊ သို့မဟုတ် လုံးဝမကြေညာကြောင်း ဖော်ပြသည်။
Browser ပံ့ပိုးမှု
undefined()
ECMAScript1 (ES1) အင်္ဂါရပ်တစ်ခုဖြစ်သည်။
ES1 (JavaScript 1997) ကို ဘရောက်ဆာအားလုံးတွင် အပြည့်အဝ ပံ့ပိုးထားသည်။
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |
နောက်ထပ် ဥပမာများ
ဥပမာ
ပြောင်းလဲနိုင်မှုကို မကြေငြာပါ-
if (typeof y === "undefined") {
txt = "y is undefined";
} else {
txt = "y is defined";
}