Constants (स्थिरहरू)

Constants were introduced in ES6(2015), and use a const keyword. Variables that are declared with const cannot be reassigned or redeclared.

स्थिरहरू ईएस ६ (2015) मा प्रस्तुत गरिएको थियो, र कन्स्ट कीवर्ड प्रयोग गर्दछ। कन्स्ट सँग घोषणा गरिएका भेरिएबलहरू पुन: असाइन गर्न वा पुन: परिभाषित गर्न सकिँदैन।

Example:

const VERSION = '1.2';

📝 Task:

  • [ ] Run the program mentioned below and fix the error that you see in the console. Make sure that the code result is 0.9 when it is fixed in the console.

  • [ ] तल उल्लिखित प्रोग्राम चलाउनुहोस् र तपाईँले कन्सोलमा देख्नुभएको त्रुटि ठीक पार्नुहोस् । निश्चित गर्नुहोस् कि कोड परिणाम ०.९ हो जब यो कन्सोलमा फिक्स गरिएको छ।

const VERSION = '0.7';
VERSION = '0.9';
console.log(VERSION);

💡 Hints:

  • Visit the Variables chapter for more info about const and also look for "TypeError assignment to constant variable" in search engines to learn a fix.

  • कन्स्टको बारेमा थप जानकारीको लागि भेरिएबल्स अध्यायमा जानुहोस् र फिक्स सिक्नका लागि खोजी इन्जिनमा "स्थिर चरमा टाइपइरर असाइनमेन्ट" पनि हेर्नुहोस्।

results matching ""

    No results matching ""