Home »
MCQs »
AngularJS MCQs
Consider the below statement – what will be the output (5)?
26. Consider the below statement – what will be the output?
<div ng-app="" ng-init="values=[10, 20, 30]">
<p>The value is {{values[0]}}, {{values[3]}}</p>
</div>
- The value is 10, 30
- The value is 10, 0
- The value is 10, NaN
- The value is 10,
Answer: D) The value is 10,
Explanation:
The output will be "The value is 10,". Because array indexing starts with 0 and ends with length of the array -1. In the above statement, there are only 3 elements and the last index is 2. Thus the statement {{values[3]}} will print nothing.