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>
  1. The value is 10, 30
  2. The value is 10, 0
  3. The value is 10, NaN
  4. 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.

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.