ES6 Recap
ES6 Recap
We've just learned a bunch of ES6.
We've learned:
Use const
and let
instead of var
const
and let
instead of var
Remember, When declaring variables using ES6 syntax, if you need to declare a variable whose value will not change, declare it as a const
. If the variable's value will or might change, unless you need a global scope, you'll likely declare it as a let
.
Use the arrow function =>
to declare a function
=>
to declare a functionUse the arrow function =>
with implicit returns to declare a function that only returns something
=>
with implicit returns to declare a function that only returns somethingUse the arrow function =>
preserves the original this
context
=>
preserves the original this
contextis now
Use literals for assigning a variable as the value of the key of the same name
The second piece of code is synonymous with the first piece of code. The second piece of code saves you from writing price: price
when you're declaring an object key-value pair inside an object.
Use template literals for string interpolation
Remember, these require you to use the tick
``` quotation mark. The single quote or double-quote marks won't invoke string interpolation.
Last updated