JavaScript Question and Answers
Q21.What is variable typing in javascript?
Ans.It is perfectly legal to assign a number to a variable and then assign a
string to the same variable as follows example
i = 10;
i = "string";
This is called variable typing
Q22.Does javascript have the concept level scope?
Ans:No. Javascript does not have block level scope,all the variables
declared inside a function possess the same level of scope unlike c,c++,java.
Q23. What are undefined and undeclared variables?
Ans:Undeclared variables are those that are not declared in the
program (do not exist at all),trying to read their values gives runtime
error.But if undeclared variables are assigned then implicit declaration is done
.
Undefined variables are those that are not assigned any value but are
declared in the program.Trying to read such variables gives special value called
undefined value. Q24. What is ===
operator ?
Ans:==== is strict equality operator ,it returns true only when the two
operands are having the same value without any type conversion.
Q25.What does the delete operator do?
Ans:The delete operator is used to delete all the variables and objects used
in the program ,but it does not delete variables declared with var keyword.
Q26.What does break and continue statements do?
Ans:Continue statement continues the current loop (if label not specified)
in a new iteration whereas break statement exits the current loop.
Q27.How to create a function using function
constructor?
AnsThe following example illustrates this
It creates a function called square with argument x and returns x multiplied by
itself.
var square = new Function ("x","return x*x");
Q28:What’s relationship between JavaScript and
ECMAScript?
Ans:
ECMAScript is yet another name for JavaScript (other names
include LiveScript). The current JavaScript that you see supported in browsers
is ECMAScript revision 3.
Q29:What are JavaScript types?
Ans: Number, String, Boolean, Function, Object, Null, Undefined.
Q30:How do you convert numbers between
different bases in JavaScript?
Ans:Use the parseInt() function, that takes a string as the first parameter,
and the base as a second parameter. So to convert hexadecimal 3F to decimal, use
parseInt ("3F", 16);
What does isNaN function do? - Return true if the argument is not a number.
<<Previous
More>>
|