Given
below array, which has two commas with no data, how it is interpreted.
var
arr = ["Cricket", , "Football"]
Missing
elements in the array are treated as undefined.
HelloWorld.js
var arr = ["Cricket", , "Football"] console.log("arr[0] : " + arr[0]); console.log("arr[1] : " + arr[1]); console.log("arr[2] : " + arr[2]);
Output
arr[0]
: Cricket
arr[1]
: undefined
arr[2] : Football
arr[2] : Football
No comments:
Post a Comment