Answer the following questions about JavaScript. These questions may require you to do your own research to determine the best answer.
Developer Resources
Javascript is a client side scripting language and the purpose of javascript is to make our pages interactive and to create responsive websites.Javascript comes with web animation API's and advanced frameworks which are used altogether to create highly responsive interfaces which improves the user experience and provide dynamic functionality. Earlier than javascript have to wait for the server to react and show another page.
Variable is a data holder to store the values and return them when it is called. Example 1 var x = 2 here x is the variable holding a value 2 Example 2 Myfunction(anyvalue){ var i = anyvalue .....logic/statement} here variable i will hold any value passed to the function asa parameter. Example 3 var qaisar = 4433 here the variable qaisar is holding value which is 4433.
var x = 10;
= will just check the euality of the value assigned x=y , x=z, then y=z == will check only the object equality and not functional equality. 0 == false will be true. === will check both object equality and functional equality. 0 === false will be false because they are of a different data type.
It will return Hello10 because "Hello" is a string and 10 is a character and when they are concatenated and run,the javascript engine read the values left to right so it will read the "Hello" first which is a string and it will take the 10 also as a string.
The for loop is known as a control flow statement and main purpose of for loop is iterartion and allow code to execute repeatedly. Advantages of for loop if we want to print soemthing on the screen e.g 100 times then we have to type the code as many times but if we use a loop we dont have to type a code again and again we will just put the code in the loop and iterate it as many time as we want.
while statement is one of the conditional statements and it will creates a loop which will run for a specific time until the condition passed on to the loop is true known as while loop. while(condition) { code }
There are 3 conditional statements which are if, else and else if. 1. If is used to specify a condition which could be true of false e.g. if (3>0) 2. else is used to specify the code block to be executed if the provided if condition is false. else {code} 3. else if is used to provide an alternate condition to be checked after the first if condition as a second condition to be checked. else if(5>3){code}
when we use an if statement inside an if statemnt its called nesting. This will happen if we nest two if conditions. if (condition 1) { if (condition 2){ i will be executed if both condition 1 and 2 will be true } i will be executed if only condition 1 is true. } Condition 2 will only be checked if condition 1 is true otherwise if condition 1 is false the condition 2 wont even be get checked at all. where as both conditions are checked in the case below if(condition 1){ code} else if (condition 2) {code} else {code}