Monday 20 February 2017

Interview Q & A: JavaScript Programming

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 –

BooleanStringNumberNullObjectFunctionUndefined

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 ‘\’.

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.

11) What is “SetTimeOut” function in javascript?

“SetTimeOut” function is used to call the function given as a parameter after some time delay. Below is the javascript code for the same –

setTimeout(function(){ alert("Text to Show"); }, 5000);

12) What is “SetInterval” function in javascript?

“SetInterval” function is used to call the function (given as a parameter) repeatedly after some time delay. Below is the javascript code for the same –

setInterval (function(){ alert("Text to Show"); }, 5000);

13) What is “ClearInterval” function in javascript?

“ClearInterval” function is used to clear the time set from function – “SetInterval()”.

14) How to give comments in javascript?

For single line comment – “//”For multi-line comments – “/* */”

15) Why to use “===” operator in javascript?

“===” operator is called strict operator and it returns true when both the values are same and returns false when the values are not same.

16) How we can submit a form using javascript?

For submitting a form from javascript we have to use – document.form[0].submit() method.

17) Will javascript support automatic conversion of type?

Yes javascript will support automatic conversion of type.

18) How we can change the style of an element from javascript?

Below code can be used to change the style of an element –

document.getElementByID(‘mytestid’).className = “testclass”;

19) How we can change the fontsize from javascript?

Below code can be used to change the font size –

document.getElementByID(‘mytestid’).style.fontsize = “12”;

20) How we can read and write file in javascript?

Below are the ways to read and write files in javascript –

Using Active X objectsUsing Javascript Extension

No comments:

Post a Comment