Skip to content
Advertisement

I am getting error push() is not a function while pushing element in array?

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

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().

Advertisement