1. Constants with const
and let
ES6 brought us const
and let
for declaring variables. const
is used for
constants, and let
for block-scoped variables.
Example:
const pi = 3.14159;
let counter = 0;
2. Arrow Functions
Arrow functions provide a concise syntax for writing functions. They also inherit the this
value from the
enclosing scope.
Example:
const add = (a, b) => a + b;
3. Template Literals
Template literals allow embedding expressions inside string literals using backticks (`
).
Example:
const name = 'John';
const greeting = `Hello, ${name}!`;
4. Conclusion
ES6 brought a wealth of improvements to JavaScript, enhancing its readability and functionality. As you explore these features, you'll find new ways to write cleaner and more efficient code.