Comment Basically two types. Single line comment and multiple line comment.
In this comment we just use // then write anything it is a single line comment.
In this comment first we use /* then write something then end */ it is a multi line comment.
2. Types Of Values-
When we declare a variable we must store values. But which types of values we can store?
Maximum case we can store number or string type value. But some developers basically beginner don’t know other types of value.
Basically there are two types of values.
1. Primitives Values
2. Object and Function
Primitives values are Undefined, Null, Boolean, Numbers, String, Symbol, BigInts.
3. Check Values-
4. Try Catch-
Finally method basically don’t care about error or not. finally method will always run he doesn’t care about error.
6. Null Vs Undefined-
null means there are no values in the variable. And undefined means there are not defined. When a variable is missing to access and it’s defined but there are no values in this that is undefined.
In this example we declared a name variable but we cannot assign any values in this that’s why when we try to print this variable it show the output undefined.
And we try to show another that is a object property age. So we declared a object but we cannot defined “age” property in this that’s why it show the output undefined.
Object is a group of data like a collection. A object have many property and many property have own values. For example if a men is an object then men has name,age,height,width etc. So men is a object and name,age,height and weight are property.
So how we can access this property of object. We need to objectName.objectProperty so if we need to print object name then we can access this like men.name
If we use distrtucture then we can access this direct name like as
Function is a block of code to complete particular task. Suppose we need to addition between two integer number. We can create a function then we push summation mathematics formula using code in this function. The function only work with summation. We can also return value from function. If we declare a function we just need to call with function name.
In this code we just declare a function and it accept two parameter named num1 and num2.
We just call a function in line 5 and we pass the two values 5 and 10 which will be summation in this function. Then In this function we direct print the value.
When we use a variable after declaration that is called hoisting.
In this example we assigned a value in variable a then we print this and then we declare. The output will be show. You can try this code.
But if we use let or const type variable then the hoisting will not work. It’s work only for var.
10. Spread Operator-
When we copy multiple values from array or object we can use spread operator. We use Spread Operator as a 3 dots like this (…).
In this code we declared two array arr1 and arr2. Then we declare another array named arr3 then we just simple copy arr1 and arr2 using spread operator then we print arr3. We notice arr1 and arr2 values are available in arr3.