A
- 不同的二叉搜索树
数据公式的解法有点高级。
R
Understanding the ECMAScript spec, part 1 v8.dev
介绍了 ECMAScript spec 中的 [[ ]]、?、 ! 的使用含义。
- 使用
[[ ]]
包含,表示的是internal slots
或internal methods
关于
?
:? Foo()
等价于ReturnIfAbrupt(Foo())
// Return ? Foo() expands to:
Let temp be Foo().
If temp is an abrupt completion, return temp.
Set temp to temp.[[Value]].
Return NormalCompletion(temp).
关于
!
// Similarly, Let val be ! Foo() is equivalent to:
Let val be Foo().
Assert: val is not an abrupt completion.
Set val to val.[[Value]].
文中给出了一个有意思的博客:https://timothygu.me/es-howto/ ,这个博客做的跟 w3c 规范的网站样式极其相似,按照 w3c 的“标准”来写博文,真是一个大佬!
T
My Favorite JavaScript Tips and Tricks Tapas Adhikary
下面列举个人觉得比较新的 Tips:
Number.isInteger(num)
: 判断一个数是否是整数event.target.valueAsNumber
: 使用 event.target.value 获取 input 中的值通常返回的是一个字符串,而使用 event.target.valueAsNumber 可直接获取输入的数值- Required Function Params: 设置必填参数提示
``javascript let isRequired = () => { throw new Error('This is a mandatory parameter.'); } let greetings = (name=isRequired(), message='Hello,') => { return
${message} ${name}`; } console.log(greetings());
- Swap variables: 交换变量
```javascript
let fire = '🔥';
let fruit = '🍉';
[fruit, fire] = [fire, fruit];
console.log(fire, fruit);
- Get Query Params: 获取地址栏参数:
let project = new URLSearchParams(location.search).get('project');
S
推荐一本书:《如何阅读一本书》