जावास्क्रिप्ट में सामान्य संक्षिप्त जाँच
संक्षिप्त जाँच अन्य डेटा प्रकारों के लिए भी
काम करती है। इस स्थिति में
यह डेटा पहले बूलियन प्रकार में
परिवर्तित किया जाता है, और फिर तुलना की जाती है
true से। उदाहरण देखें:
let test = 3;
if (test) {
console.log('+++'); // यह काम करेगा
} else {
console.log('---');
}
वास्तव में दिया गया कोड निम्नलिखित के बराबर है:
let test = 3;
if (Boolean(test) === true) {
console.log('+++');
} else {
console.log('---');
}
कोड चलाए बिना, निर्धारित करें कि कंसोल में क्या प्रिंट होगा:
let test = 3;
if (test) {
console.log('+++');
} else {
console.log('---');
}
कोड चलाए बिना, निर्धारित करें कि कंसोल में क्या प्रिंट होगा:
let test = 'abc';
if (test) {
console.log('+++');
} else {
console.log('---');
}
कोड चलाए बिना, निर्धारित करें कि कंसोल में क्या प्रिंट होगा:
let test = '';
if (test) {
console.log('+++');
} else {
console.log('---');
}
कोड चलाए बिना, निर्धारित करें कि कंसोल में क्या प्रिंट होगा:
let test = 3 * 'abc';
if (test) {
console.log('+++');
} else {
console.log('---');
}
कोड चलाए बिना, निर्धारित करें कि कंसोल में क्या प्रिंट होगा:
let test = null;
if (test) {
console.log('+++');
} else {
console.log('---');
}
कोड चलाए बिना, निर्धारित करें कि कंसोल में क्या प्रिंट होगा:
let test = false;
if (test) {
console.log('+++');
} else {
console.log('---');
}
कोड चलाए बिना, निर्धारित करें कि कंसोल में क्या प्रिंट होगा:
let test;
if (test) {
console.log('+++');
} else {
console.log('---');
}
कोड चलाए बिना, निर्धारित करें कि कंसोल में क्या प्रिंट होगा:
let test = 0;
if (test) {
console.log('+++');
} else {
console.log('---');
}
कोड चलाए बिना, निर्धारित करें कि कंसोल में क्या प्रिंट होगा:
let test = '0';
if (test) {
console.log('+++');
} else {
console.log('---');
}
कोड चलाए बिना, निर्धारित करें कि कंसोल में क्या प्रिंट होगा:
let test = -1;
if (test) {
console.log('+++');
} else {
console.log('---');
}