I've accidentally came across this weird buggy phenomenon when writing code with Nodejs.
I get input from a form, which are comprised of a series of ID's, delimited with New Line(hit Enter)
To handle them, I use the split function to split them into an array:
var array = orig_input.split('\n');
For the debugging purpose,I print them.
console.log('orig_input = ' + input);
console.log('array = ' + array);
Well, here comes the first weird output:
orig_input = 1111
2222
,2222
Look! the supposed output string 'array = 1111' is swallowed !
My first thought is array[0] has some delete characters.
So I change the code to do some tests, like:
console.log('orig_input = ' + input);
console.log('***********************************' + array[0] + array[1]);
Wow, yet another weird output:
orig_input = 1111
2222
2222*******************************1111
It seems there is some weird wrap or something.
And finally, after some boring testing and debugging, it turns out that
I used the wrong split character, it should be '\r\n', instead of '\n'
We know that the former is the MS-style of new line, and the latter is the *nix-style of new line.
So question is
Is this a bug of console.log function in **Nodejs** ?
Anyone would explain this?