ES6 introduced the let
which allows to a block scope declaration of the varibles unlike var
which will declare a variable globally or locally to the entire function regardless of any inner scopes declared (i.e. a variable declared using var
will be accessed ant where in the glabal scope or inside the function).
ES6 also introduced the const
keyword, which cannot be redeclared or reassigned, but is not immutable, meaning, if you store an object, you may edit this object’s content.
A shorter way of declaring functions, takes the formula of parameters => expression, it can’t be used as method, or constructor, does not have prototype, and using this
will refer to the global scope itself.
Using the ${variable name} will let you call varibles inside strings, multi line strings also can be written but whitespace must be taken into consideration.
Inside classes there is no need to write function
to declare a method.
Calling variables inside an object is enough if you want to tur them to properties.
class
is used to declare a class, constructor
is used to set object properties, and extends
for inherting (making a subclass of a class)
React is a component library based on JS in which JSX
is used to write HTML component inside JavaScript synatx and you can also use{}
to write expressions inside HTML, JSX also helps preventing injection attacks by escaping any embedded values before rendering them.