Important Interview Questions: Javascript Version - Part 4

What are all the types of Pop up boxes available in JavaScript?

window.alert('Hi! I am an ALERT BOX!')

window.confirm('Please Confirm me. I am CONFIRM BOX!')

window.prompt('I am PROMPT BOX! I am the question', 'I am the default text!')

What is the use of void(0)?

The void operator is often used merely to obtain the undefined primitive value, usually using “void(0)” (which is equivalent to “void 0”). In these cases, the global variable undefined can be used.

How can a page be forced to load another page in JavaScript?

<script language="JavaScript" type="text/javascript">
    location.href = 'link to be opened comes here'
</script>

What is the data type of variables in JavaScript?

All variables in JavaScript are of the object data type.

What is the difference between an alert box and a confirmation box?

What are escape characters?

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.

console.log('Without 'escape' characters!')
// prints an error

console.log('With \'escape\' character!')
// prints: With 'escape' character!

What are JavaScript Cookies?

When a browser requests a web page from a server, cookies belonging to the page are added to the request. This way the server gets the necessary data to “remember” information about users.

Explain what is the pop() method in JavaScript?

The pop method removes the last element from an array and returns that value to the caller. pop is intentionally generic; this method can be called or applied to objects resembling arrays.

Whether JavaScript has a concept level scope?

No. JavaScript does not have a concept-level scope. The variable declared inside the function has scope inside the function.

Mention what is the disadvantage of using innerHTML in JavaScript?