Tuesday, October 20, 2015

Javascript Interview Questions and Answers

1) What is Javascript?
Javascript is a client side scripting language which is understood by the browsers and will be added in the HTML code.
2) Explain Javascript Types?
Below are some javascript types –
  • Boolean
  • String
  • Number
  • Null
  • Object
  • Function
  • Undefined
3) Why to use NaN in javascript?
“NaN” function is used check the number in the argument. If it does not contain number then it will return true else it will return false.
4) Explain negative infinity?
“Negative Number” is a number which is obtained from dividing the negative number by zero.
5) Can javascript code be broken into multiple lines?
Yes it is possible to break the javascript code to multiple lines using backslash ‘\’.
Eg: document.write(“My Test \a Content”);
6) What are undeclared variables in javascript?
Undeclared variables are the ones which does not exist and are not declared in the program. So while running the program runtime error will be thrown.
7) What are undefined variables in javascript?
Undefined variables are the ones which exist in the program but are not defined or not assigned any value for that variable.
8) Explain global variables in javascript?
If the variable can be accessed anywhere in the code is called global variables and these will not have any scope in the application.
9) Explain Prompt box in javascript?
Prompt box is used to get the input from the user by popping up the window to the user.
10) Why to use “this” keyword in javascript?
‘this’ keyword is used to refer the current object in the program. “this” keyword is used mainly inside the method to refer to the current variable or current object.

No comments: