Baseline 2023
Newly available
toSorted()
㯠TypedArray
ã¤ã³ã¹ã¿ã³ã¹ã®ã¡ã½ããã§ã sort()
ã¡ã½ããã®ã³ãã¼ã¡ã½ããçã§ããããã¯ãè¦ç´ ãæé ã«ã½ã¼ãããæ°ããåä»ãé
åãè¿ãã¾ãããã®ã¡ã½ãã㯠Array.prototype.toSorted()
ã¨åãã¢ã«ã´ãªãºã ã§ãããæ¢å®ã§æååã¨ãã¦ã§ã¯ãªãæ°å¤ã¨ãã¦å¤ãã½ã¼ãããç¹ãç°ãªãã¾ãã
toSorted()
toSorted(compareFn)
弿°
compareFn
çç¥å¯
ã½ã¼ãé ãå®ç¾©ãã颿°ã§ããè¿å¤ã¯ã 2 ã¤ã®è¦ç´ ã®ç¸å¯¾é åºã示ã符å·ãæã¤æ°å¤ã§ãªããã°ãªãã¾ããã
a
æ¯è¼ã®ããã®æåã®è¦ç´ ã§ãã
b
æ¯è¼ã®ããã® 2 ã¤ç®ã®è¦ç´ ã§ãã
è¦ç´ ãæé ã«ã½ã¼ãããæ°ããåä»ãé åã§ãã
解説詳細ã«ã¤ãã¦ã¯ã Array.prototype.toSorted()
ãã覧ãã ããããã®ã¡ã½ããã¯æ±ç¨çã§ã¯ãªããåä»ãé
åã¤ã³ã¹ã¿ã³ã¹ã«å¯¾ãã¦ã®ã¿å¼ã³åºããã¨ãã§ãã¾ãã
ãã®ä»ã®ä¾ã«ã¤ãã¦ã¯ã Array.prototype.sort()
ã¡ã½ãããã覧ãã ããã
const numbers = new Uint8Array([40, 1, 5, 200]);
const numberSorted = numbers.toSorted();
console.log(numberSorted); // Uint8Array [ 1, 5, 40, 200 ]
// é常ã®é
åã¨ã¯ç°ãªããæ°å¤ã®ä¸¦ã¹æ¿ãã§ã¯æ¯è¼é¢æ°ã
// è¦æ±ããã¾ããã
console.log(numbers); // Uint8Array [ 40, 1, 5, 200 ]
仿§æ¸ ãã©ã¦ã¶ã¼ã®äºææ§ é¢é£æ
å ±
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4