Home »
MCQs »
JavaScript MCQs
What is the output of the following JavaScript code? | Question 14
63. What will be the output of the following JavaScript code?
<script>
var msgs=new Array("Hello","Hey","Morning!");
for (i=0;i<msgs.length;i++){
document.write(msgs[i] + " | ");
}
</script>
- Hello | Hey | Morning! |
- Hello | Hey |
- ValueError
- TypeError
Answer: A) Hello | Hey | Morning! |
Explanation:
In the above JavaScript code, the array is declared using the new operator and all elements are printing using the loop. Thus, the output would be "Hello | Hey | Morning! |".