console ऑब्जेक्ट का उपयोग
एरर कंसोल में मैसेज प्रिंट करने के लिए, console ऑब्जेक्ट का उपयोग करें।
विभिन्न लॉग लेवल्स
- console.error(message); - लाल एरर मैसेज दिखाएगा
- console.log(message); - डिफ़ॉल्ट मैसेज देगा
- console.warn(message); - वार्निंग मैसेज देगा
- console.info(message); - इन्फॉर्मेशन मैसेज देगा
CSS के साथ लॉग मैसेज
console.log('%c Add message!, "background: green; color: white;");
वेरिएबल के साथ एरर प्रिंट करना
console.error('num=%d', num);
पूरी API रेफरेंस के लिए, Console API Reference देखें।