We are waiting for answer : Abhinav Sharma , Avanish Kumar (Host) |
Answer : Using arguments.length property, we can get the total number of arguments passed to a function. For example −
function test(x){
console.log(typeof x, arguments.length);
}
test(); //==> "undefined", 0
test(1); //==> "number", 1
test("1", "2", "3"); //==> "string", 3
Question 2 : What typeof returns for a null value?(typeof null)
Answer : It returns "object".
Question 3 : What is the result for this ?
var x; // declaring x
console.log(x); //output: undefined
console.log(y); // Output: ReferenceError: y is not defined
In JavaScript, if you try to use a variable that doesn't exist and has not been declared, then JavaScript will throw an error var name is not defined and script will stop executing. However, if you use a variable that declare but not defined, then it will return undefined.
Question 4 : Explain the difference between “==” and “===”?
Answer : “==” checks only for equality in value whereas “===” is a stricter equality test and returns false if either the value or the type of the two variables are different.
Question 5 : When we use for-in loop?
Answer : The for-in loop is used to loop through the properties of an object.
The syntax for the for-in loop is –
for (variable name in object){
statement or block to execute
}
In each repetition, one property from the object is associated to the variable name, and the loop is continued till all the properties of the object are depleted.
Question 6 : Methods GET and POST in HTML forms - what's the difference?
Answer : GET: Parameters are passed in the query string. Maximum amount of data that can be sent via the GET method is limited to about 2kb.
POST: Parameters are passed in the request body. There is no limit to the amount of data that can be transferred using POST. However, there are limits on the maximum amount of data that can be transferred in one name/value pair.
Question 7 : What is the result of 2+5+"8"?
Answer : Since 2 and 5 are integers, this is number arithmetic, since 8 is a string, it’s concatenation, so 78 is the result.
Question 8 : How to open a window with no toolbar, but with the location object?
Answer : window.open();
Winner : Ishita Paliwal, Taruna Kunwar |
Comments
Post a Comment