I want to add only integers and ignore others in a particular array. I want to add this condition on that array's push event.
Array.prototype.push = function(){
if(condition){
//execute push if true
}
else
{
//return false
}
}
Help me how to code this? This affects all the array in my code. I want to check this condition on push only for a particular array. what are the ways to achieve it?