कंसोल जोर ()
उदाहरण
कंसोल को एक संदेश लिखें:
console.assert(x + y == 11, "Expression returned false");
कंसोल पर ऑब्जेक्ट लिखें:
const myObj = {firstname:"John", lastname:"Doe"};
console.assert(x + y == 11, myObj);
नीचे और अधिक उदाहरण।
परिभाषा और उपयोग
विधि कंसोल को assert()
एक संदेश लिखती है यदि कोई व्यंजक false
.
वाक्य - विन्यास
console.assert(expression, message)
मापदंडों
Parameter | Description |
expression | Required. Any expression. If the expression evaluates to false , a message
is written in the console. |
message | Required. The message to write in the console. |
और ज्यादा उदाहरण
एक तत्व की जाँच करें:
console.assert(document.getElementById("demo"), "You have no element with ID 'demo'");
कंसोल के लिए एक सरणी लिखें:
const myArr = ["Orange", "Banana", "Mango", "Kiwi" ];
console.assert(x + y = 11, myArr);
ब्राउज़र समर्थन
console.assert()
सभी ब्राउज़रों में समर्थित है:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |