this above style is marked as a bad comment style.It is encouraged to use the below style for commenting.
**Those function having ‘try..catch ’ clause and also using ‘setTimeout’ function — this setTimeout function must be applied to whole function not just in ‘try’ clause.Just look at the examples below
The above example will not work properly.catch will run before the try clause .And there will be no error as try clause hasn’t even run yet!Now look at the below example-
This will work properly. As the setTimeout function is applied to the main function not just in ‘try’.
**Let’s think code within a function excuted properly , but this execution is not fullfilling all your requirements such as one information is missing , or output value is negative which was not supposed to be negative! What to do?
Here comes ‘throw’ operator! It is used to generate coder’s own error.Look at the example give below-
Here , coder has created an error message when she is not getting username. So , in spite of smooth excution , it will return an error set by coder for providing incomplete data.
**try..catch works like this or that . You can’t have both! But that’s not all! There is another code clause ‘finally’! It will run for sure no matter if the code ran smoothly or caught an error. Loot at the example below-
** Outside the try..catch code clause what if there is an fatal error? The user never wants to see the site to crash . It creates such irritation! And even if there is an unwanted, unexpected error ,they want to be informed about it. They don’t like to feel clueless. For this purpose , Globalcatch is used.
**Let’s be clear about ‘unidentified’ and ‘null’ data types.
Unidentified is unintentional missing values such as declaring a variable without initializing it with a value will have data type and value ‘undefined’.Where null is intentional missing values.
**The values of undefined and null is equivalent but the type is different.What I am trying to say would be clear enough through the code below-