fe
fe copied to clipboard
现代编程语言最有趣的 10 大特性
对于 2 模式匹配 Pattern matching 有一个 js 库:
- https://github.com/z-pattern-matching/z
代码示例:
const { matches } = require('z')
const result = matches(1)(
(x = 2) => 'number 2 is the best!!!',
(x = Number) => `number ${x} is not that good`,
(x = Date) => 'blaa.. dates are awful!'
)
console.log(result) // output: number 1 is not that good