Alright, I have a function
function foo(input) {
input = input.split("\n");
console.log(input);
}
and the input is 'alert("gsasdgasdg")'
so foo('alert("gsasdgasdg")')
the output I get when I run it in nodejs is the expected output: [ 'alert("gsasdgasdg")' ]
`
Now I will add a simple loop,
function foo(input) {
var output = "";
input = input.split("\n");
console.log(input);
for (var i in input) {
console.log(input[i]);
}
}
Now I get the first console.log
output as [ 'alert("gsasdgasdg")' ]
(expected) but there should be only one console.log
when it loops through the array, what I get is alert("gsasdgasdg")
(expected) and then [Function]
as far as I know nodejs should have not of converted this string into a function, any insight that explains why this happens?