I am getting error push() is not a function while pushing element in >array? giving me error lik arry.push is not a function
JavaScript
x
9
1
var abc=["get","get","get","get","get","get","get","get","get",];
2
3
for(i=0;i<abc.length;i++){
4
5
let a=abc[i].push("mate");
6
7
console.log(abc);
8
}
9
Advertisement
Answer
You should delete the [i] in abc[i].push()
because abc[i]
is string, but the .push()
method works for arrays. Therefore you should use abc.push()
instead of abc[i].push()
.