I was working on a small javascript coding challenge that was simple enough, but ran into a odd bit of strange behavior that I couldn't find documented anywhere. Maybe someone could point me to where it states that this is expected behavior?
myIntegerArray = [1,2,3,4];
b = new Array();
for(var v in a)
{
b.push(v);
}
console.log(b); // returns ["1","2","3","4"]. Note String result
If I were to use the forEach() however I get an array of Numbers back:
a.forEach(function(element,index,ay)
{
b.push(element)
});
//a console.log(b) will return [1,2,3,4]