We are going to learn the below topics in this course.
Variables & Data Types
Method for strings, arrays, objects etc
Loops- for, while, for..of
Conditionals (if, ternary & switch)
Functions(normal & arrow)
We will first look into console.log(), which is a way to write anything in console and very helpful while debugging. In jsbin we need to click on the run after that and it will show our text in Console.
One more thing is that in all browser by right-clicking and Inspect, we can open the browser console. So, we can get the output in it also.
error and warn
var have a problem of been functional scoped and not block scoped. To solve this let was introduced.
const stands for constant and we cannot redeclare it. We can add element to Array and Object declared as const, but we will look into them later.
Note: To not show anything in console we comment it out by adding two backslashes infront of it, as we did for the three console statements.
To see the real difference between var and let, we will wrap two declarations inside a if statement(we are soon going to learn about it).
The var value is accessible even outside the if statement, but the let is not accessible and the fourth console.log is giving error. The scope of if is known as block scope.
var and let
Now, var is functional scope which means it will not be accessible outside a function. We will learn about functions soon. Here, the second console.log is throwing error.
Now, lastly as with const they are not allowed to be assigned values again. So, when we are trying to re-assigning the num4 value it is giving us error.
Now, Symbol were added in ES6 and a bit complicated for this course. So, we are not going to look into it and also not used that much.
First one is a string. You can use both single and double quotes.
Fourth one is boolean and can have false value also.
Sixth and seventh one are undefined, which again means empty value. But if we don’t assign any value like in seventh one, JS assign undefined to it.
This completes part-1 of the series. You can find the jsbins used in this part below.