sort函数的输出

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"]


天涯尽头无女友
浏览 633回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript