what is wrong with this below code ? why it is printing size of array as zero?
function test() {
var arr = [];
for(var i = 0; i < 10; i++)
{
console.log('i ->' + i);
arr.push[i];
}
console.log('\n' + 'array length :' + arr.length);
}
--
Output:
i ->0
i ->1
i ->2
i ->3
i ->4
i ->5
i ->6
i ->7
i ->8
i ->9
array length :0
--
it is printing as zero(0)
[]... tryarr.push(i);.