This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## git for windows会自动替换LF 和CRLF的bug | |
```js | |
git config --global core.autocrlf false | |
``` | |
如上设置后,不会再自动替换了 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## BFC | |
除了visible外,其它值都会触发BFC,去除浮动影响 | |
## overflow:scroll 与 overflow:auto | |
__scroll__ | |
始终显示滚动条 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 转义uri | |
function uncodeHTML(str) { | |
return str.replace(/(<)|(&npsp;)|(>)|(&)|(")|(')/g, | |
function($0, $1, $2, $3, $4, $5, $6) { | |
return ($1 && '<') || ($2 && ' ') || ($3 && '>') || ($4 && '&') || ($5 && '"') || ($6 && '\''); | |
}); | |
} | |
console.log(uncodeHTML('测试<测试2&npsp;测试3>测试4&测试5"测试6'测试7<')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## webview中JavaScript中的UI线程阻塞 | |
* 如果在webview中执行逻辑,并且没有阻塞UI相关的显示(如alert,悬浮对话框等,toast不影响),这时候是可以正常执行逻辑的 | |
* 但是如果在逻辑中加了一个alert(或其他悬浮框等会阻塞UI的显示),这时候,所有的逻辑都会被阻塞住。直到页面这个阻塞消失(如点击确认按钮),才会继续接下来的逻辑 | |
归根结底,这个问题的关键是JS是一个单线程操作(虽然有异步,但是仍然是单线程),所以只要是阻塞UI线程操作都会阻塞所有的逻辑。 | |
容易出现的场景: | |
* 先执行一个setTimeout(bizlogic1)-一个短期的演示 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## JS中的数值范围 | |
JS中Number类型的实质是64位浮点数 | |
所以表示的范围是:`正负1.7976931348623157乘以10的308次方` | |
这两个边界值可以分别通过访问Number对象的MAX_VALUE属性和MIN_VALUE属性来获取 | |
能表示的最小小数是:`正负5乘以10的负324次方` | |
对于整数,在ECMAScript5规范中规定,无论正负数的值都不能大于`2^53`,在这个范围内,js的计算时精确的,一旦超出,js依旧可以计算,但是无法保证数值的精确。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 描述 | |
一个页面中,使用了IScroll5作为下拉刷新,使用mui监听tap事件。 | |
结果点击时出现两次tap事件,而其它地方监听则不会出现两次 | |
## 分析 | |
通过分析,最终问题锁定为: IScroll5中的probe源码中如果启用了tap,点击时会手动抛出一次tap时间。而mui(或者JQ)本身也会监听一次tap,导致了2次的bug | |
## 解决 | |
下拉刷新创建IScroll时,禁用tap `options.tap=false`,这样就不会影响其它第三方tap插件了 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## ECMA-262 描述了一组具有特定用途的关键字。 | |
这些关键字可用于表示控制语句的开始或结束,或者用于执行特定操作等。 | |
按照规则: | |
关键字是语言保留的,不能用作标识符 | |
| :------------- |:-------------:|:-----:|-----:| | |
| break | do | instanceof | typeof | | |
| case | else | new | var | | |
| catch | finally | return | void | | |
| continue | for | switch | while | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 获取时间戳的几种方法 | |
``` | |
var timestamp = Date.parse(new Date()); | |
// 结果例如: 1280977330000(毫秒变为了000显示) | |
``` | |
``` | |
var timestamp = (new Date()).valueOf(); | |
// 1280977330748 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 原则 | |
* 永远不要修改arguments对象 | |
* 使用[].slice.call(arguments)得到一个arguments对象的拷贝,然后对拷贝进行修改等操作 | |
### 一些严格模式下arguments常见错误 | |
``` | |
function strict(x) { | |
"use strict"; |
NewerOlder