| let list = [1, 2, 3, 10, 11, 12, 20, 21, 22, 100, 102, 103, 200, 201, 202, 130, 220]; |
| |
| |
| let collator = Intl.Collator(undefined, { numeric: true }); |
| |
| list.sort(); |
| list.sort(collator.compare); |
| let namelist = [ |
| '陈坤', |
| '邓超', |
| '杜淳', |
| '冯绍峰', |
| '韩庚', |
| '胡歌', |
| '黄晓明', |
| '贾乃亮', |
| '李晨', |
| '李易峰', |
| '鹿晗', |
| '井柏然', |
| '刘烨', |
| '陆毅', |
| '孙红雷' |
| ]; |
| namelist.sort(); |
| namelist.sort(new Intl.Collator('zh').compare); |
| const format = new Intl.DateTimeFormat('zh-Hans', { |
| year: 'numeric', |
| month: '2-digit', |
| |
| day: '2-digit', |
| hour: '2-digit', |
| minute: '2-digit', |
| second: '2-digit', |
| hour12: false |
| }) |
| |
| |
| const format2 = new Intl.DateTimeFormat('zh-CN', { |
| year: 'numeric', |
| month: 'long', |
| day: 'numeric', |
| hour: 'numeric', |
| minute: 'numeric', |
| second: 'numeric' |
| }); |
| |
| |
| format.format(new Date()); |
| format2.format(new Date()); |
| |
| var vehicles = ['Motorcycle', 'Bus', 'Car']; |
| |
| var formatter = new Intl.ListFormat('en', { style: 'long', type: 'conjunction' }); |
| console.log(formatter.format(vehicles)); |
| Intl.NumberFormat(undefined, { |
| minimumFractionDigits: 10 |
| }).format(123456789056.123); |
| |
| new Intl.NumberFormat('zh-Hans', { |
| style: 'currency', |
| currency: 'CNY', |
| currencyDisplay: 'name' |
| }).format(12345.6789); |
| |
| '星期' + new Intl.NumberFormat('zh-Hans-CN-u-nu-hanidec').format(new Date().getDay()); |
| |
| new Intl.NumberFormat('zh-Hans-CN-u-nu-hanidec', { |
| style: 'currency', |
| currency: 'CNY', |
| currencyDisplay: 'name', |
| useGrouping: false |
| }).format(1234); |
| new Intl.PluralRules('ar-EG').select(0); |
| |
| new Intl.PluralRules('ar-EG').select(1); |
| |
| new Intl.PluralRules('ar-EG').select(2); |
| |
| new Intl.PluralRules('ar-EG').select(6); |
| |
| new Intl.PluralRules('ar-EG').select(18); |
| |
| let rtf = new Intl.RelativeTimeFormat('zh', { |
| numeric: 'auto' |
| }); |
| |
| rtf.format(-1, 'day'); |
| rtf.format(1, 'day'); |
| rtf.format(-365, 'day'); |
| Intl.getCanonicalLocales('zh-hans'); |
| |
| Intl.getCanonicalLocales('zh'); |
| |
| Intl.getCanonicalLocales('zh-cmn-Hans-CN'); |
| |
| Intl.getCanonicalLocales('zh-cn'); |
| |
| Intl.getCanonicalLocales('yue-hk'); |
| |
| Intl.getCanonicalLocales('zh-some'); |
| |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!