I have a small question which troubled me one afternoon.yes I'm new to JavaScript and so sorry for asking a easy question,I think I won't sleep if I can't figure out this bug.Here is the cade:
var a = [1, 3, 5, 7, 5, 3];
console.log(a);
/*Array[6]
0:1
1:3
2:3
3:5
4:5
5:7*/
alert(a);//1,3,5,7,5,3
var b = a.sort();
console.log(a);
/*Array[6]
0:1
1:3
2:3
3:5
4:5
5:7*/
alert(a);//1,3,3,5,5,7
I dont understand why "console.log(a)" had sorted before I call function.But alert run well.Thanks so much for answering.