Java Script Interview Questions and Answers Part 4

1. What is the data type of variables of in JavaScript?

Ans. All variables in the JavaScript are object data types.

2. Difference between an alert box and a confirmation box?

Ans. An alert box displays only one button which is the OK button.

But a Confirmation box displays two buttons namely OK and cancel.

3. Explain escape characters?

Ans. Escape characters (Backslash) is used when working with special characters like single quotes,

double quotes, apostrophes and ampersands. Place backslash before the characters to make it

display.

4. Explain JavaScript Cookies?

Ans. Cookies are the small test files stored in a computer and it gets created when the user visits the

websites to store information that they need. Example could be User Name details and

shopping cart information from the previous visits.

5. What is pop()method in JavaScript?

Ans. The pop() method is similar as the shift() method but the difference is that the Shift method

works at the end of the array. Also the pop() method take the last element off of the given array

and returns it. The array on which is called is then altered.

6. Whether JavaScript has concept level scope?

Ans. No It doesn’t.

        JavaScript does not have concept level scope. The variable declared inside the function

        has scope inside the function.

7. Mention what is the disadvantage of using innerHTML in JavaScript?

Ans. If you use innerHTML in JavaScript the disadvantage is Content is replaced everywhere we cannot use like “appending to innerHTML”Even if you use +=like “innerHTML = innerHTML + ‘html’” still the old content is replaced by html. The entire innerHTML content is re-parsed and build into elements, therefore it is much slower. The innerHTML does not provide validation and therefore we can potentially insert valid and broken HTML in the document and break it






Subscribe

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

Delivered by FeedBurner

Protected by Copyscape Duplicate Content Checker