迷渡

Results 171 comments of 迷渡

### 对于不支持的浏览器,是否有 polyfill 方案? **很遗憾,没有**。只有一个 [shim](https://gist.github.com/paullewis/55efe5d6f05434a96c36) 方案。 ```javascript window.requestIdleCallback = window.requestIdleCallback || function (cb) { return setTimeout(function () { var start = Date.now(); cb({ didTimeout: false, timeRemaining: function () {...

正则,函数,日期都可以,因为控制台会隐式调用这几个 `Object` 的 `toString` 方法。 子类同样适用: ```js class MyDate extends Date {}; var f = new MyDate(); f.toString = function () { console.log(performance.now()); return performance.now(); } console.log('%s', f); ``` ----------...

@Tao-Quixote 是的,这个主要是用在移动端,而且推荐使用 `scrollIntoViewIfNeeded`

我在这篇文章 [论腾讯 TFC 抽奖程序作弊的可能性,以及代码中存在的 bug](https://zhuanlan.zhihu.com/p/27571967) 有深入的讨论。 --------------------- 在**旧浏览器**中我们经常使用这样的奇技淫巧提升性能。 我们看看这些操作的性能对比,来自 [jsperf](https://jsperf.com/jsfvsbitnot/8) ![image](https://user-images.githubusercontent.com/359395/27825390-efd72984-60e1-11e7-8832-afcbe8956d85.png) 结果很出乎我们的意料,位运算并没有我们想象中的那么快。而且,我们也应该相信 JS 引擎在不断的进化。 如果为 `parseInt` 传递第二个参数,`parseInt` 还会更快。(_待补充测试用例_) --------- 再补一个 [jsperf](https://jsperf.com/math-floor-vs-math-round-vs-parseint/52) 由于我没有截多屏的工具,所以自己点进去运行吧。

`parseInt` 并**不是取整**。看函数签名: > parseInt(string, radix); `parseInt()` 函数解析一个字符串参数,并返回一个指定基数的整数 (数学系统的基础)。 -------------------- 对比 `parseInt` 和 `~~`: ## 非常小的数: ```javascript > ~~0.0000000003 0 > parseInt(0.0000000003) 3 > Math.floor(0.0000000003) 0 ``` 因为 `0.0000000003` 会使用科学计数法表示为 `3e-10`,`parseInt`...

文档 [Intl - MDN](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Intl) 兼容性:https://caniuse.com/#search=Intl

`` 确实不管用。 只能使用奇技淫巧了:在表单最上面新建两个用户名和密码的隐藏的 `input`。

https://developer.mozilla.org/zh-CN/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion

@wuxianqiang 你没认真看我的回复吧 ![](https://user-images.githubusercontent.com/359395/41217857-c51d36ae-6d8b-11e8-85b2-fe9c3260e221.png)