随便记记,一些零碎的东西
-
Java 抛出异常之后的代码不会执行,除非抛出语句被 try-catch 处理了
-
JavaScript 中有
null、undefined、''、0、false这几个常见变量,如何优雅的判断?
- 同时判断 null、undefined、数字零、false、''
!exp - 空字符串 ''
''.length === 0 - 全是空格的字符串 ' '
strings.replace(/(^s*)|(s*$)/g, '').length === 0 - 判断 undefined
undefined == null, true
undefined === null, false
常见判断
- 从数组中删除对象
const numbers = [1, 1, 20, 3, 3, 3, 9, 9];
const uniqueNumbers = [...new Set(numbers)]; // -> [1, 20, 3, 9]
... 表示将任何可迭代对象转成数组
4. 简单的判断并返回
maybeSomething ?? "Nothing found"
- BigDecimal.compareTo 返回结果:
- a > b 返回 1
- a = b 返回 0
- a < b 返回 -1
-
Java 将 List 转字符串并添加分隔符:
- stream().map(e -> "?").collect(Collectors.joining(","))
- String.join()
-
npm 查看版本
npm viewversions --json
本文来自博客园,作者:别忘抬头望天空,转载请注明原文链接:https://www.cnblogs.com/blog4linyi/p/16088133.html
浙公网安备 33010602011771号