function findShort(s){
return Math.min(...s.split(" ").map (s => s.length));
}
var p1 = findShort("bitcoin take over the world maybe who knows perhaps"); //3
var p2 = findShort("turns out random test cases are easier than writing out basic ones") //3
console.log(p1); //3
console.log(p2); //3
找出最短的长度的字符串,这里的...起到什么作用?这好像不是类数组把。。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
业精于勤,荒于嬉;行成于思,毁于随。