Constants in Javascript
Understanding constants and variable declarations in JavaScript is fundamental. Learn the differences between var, let, and const.
Key Concepts
- const - cannot be reassigned
- let - block scoped, can be reassigned
- var - function scoped, hoisted
- Choose the right declaration for your needs
Example 1
Code
export const cars = [ { id: 1, name: 'Nexon', brand: 'Tata', make: '2017' }, { id: 1, name: 'Verna', brand: 'Hyundai', make: '2008' }, { id: 1, name: 'Bolero', brand: 'Mahinda', make: '2012' } ]
Summary
Understanding constants is essential for mastering javascript. Practice these examples and experiment with variations to deepen your understanding.
Key Takeaways
- constants is a fundamental concept in javascript
- Practice with these examples to build confidence
- Experiment with variations to explore edge cases
- Understanding constants will help you in technical interviews