Java Script Interview Questions and Answers Part 2

1. What is a prompt box?

Ans. A prompt box is a box which allows the user to enter input by providing a text box. Label and box will be provided to enter the text or number.

2. Explain the working of timers in JavaScript? Also elucidate the drawbacks of using the timer, if any?

Ans. Timers are used to execute a piece of code at a set time or also to repeat the code in a given interval of time. This is done by using the functions setTimeout, setInterval and clearInterval.

The setTimeout(function, delay) function is used to start a timer that calls a particular function after the mentioned delay. The setInterval(function, delay) function is used to repeatedly execute the given function in the mentioned delay and only halts when cancelled.

The clearInterval(id) function instructs the timer to stop.

Timers are operated within a single thread, and thus events might queue up, waiting to be executed.

3. What is ‘this’ keyword in JavaScript?

Ans. ‘This’ keyword is used to point at the current object in the code. For instance: If the code is presently at an object created by the help of the ‘new’ keyword, then ‘this’ keyword will point to the object being created.

4. Which symbol is used for comments in Javascript?

Ans.      // for Single line comments and

/* Multi

Line

Comment

*/

5. What is the difference between ViewState and SessionState?

Ans. ‘ViewState’ is specific to a page in a session.

‘SessionState’ is specific to user specific data that can be accessed across all pages in the web application.

6. Explain how can you submit a form using JavaScript?

Ans. To submit a form using JavaScript use document.form[0].submit();

document.form[0].submit();

7. Does JavaScript support automatic type conversion?

Ans. Yes JavaScript does support automatic type conversion, it is the common way of type conversion used by JavaScript developers.

8. What is === operator?

Ans. === is called as strict equality operator which returns true when the two operands are having the same value without any type conversion.

9. How can you convert the string of any base to integer in JavaScript?

Ans. The parseInt() function is used to convert numbers between different bases. parseInt() takes the string to be converted as its first parameter, and the second parameter is the base of the given

string.

10. What is called Variable typing in Javascript?

Ans. Variable typing is used to assign a number to a variable and the same variable can be assigned

         to a string.






Subscribe

Receive Quality Tutorials Straight in your Inbox by submitting your Email below:

Delivered by FeedBurner

Protected by Copyscape Duplicate Content Checker