code1
var fruit = ['cherries', 'apples', 'bananas']; fruit.sort();
运行后输出结果是
var fruit = ['cherries', 'apples', 'bananas']; fruit.sort();
["apples", "bananas", "cherries"]
code2
var fruit = ['cherries', 'apples', 'bananas']; fruit.sort(); console.log(fruit);
运行后输出结果还是
var fruit = ['cherries', 'apples', 'bananas']; fruit.sort();
["apples", "bananas", "cherries"]
为何不是
var fruit = ['cherries', 'apples', 'bananas']; fruit.sort();
["apples", "bananas", "cherries"]
["apples", "bananas", "cherries"]
相关分类