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