-
Notifications
You must be signed in to change notification settings - Fork 9
pitfall
陳鍾誠 edited this page Sep 30, 2018
·
4 revisions
- https://medium.com/northcoders/understanding-bugs-and-errors-in-javascript-675ebb0a109a (讚!)
- http://coredogs.com/lesson/finding-javascript-bugs.html
- https://www.toptal.com/javascript/10-most-common-javascript-mistakes
- https://www.artificialworlds.net/presentations/javascript-wtfs/javascript-wtfs.html (讚!)
- https://stackoverflow.com/questions/2749952/what-are-the-top-javascript-pitfalls
- https://secure.phabricator.com/book/phabflavor/article/javascript_pitfalls/
- https://www.codementor.io/thinker3197/avoid-common-pitfalls-in-javascript-u0hzz2nfw
- https://www.toptal.com/python/top-10-mistakes-that-python-programmers-make
- https://stackoverflow.com/questions/1011431/common-pitfalls-in-python
D:\test>node
> 0.1+0.2
0.30000000000000004
> (0.1+0.2)===0.3
false
> 3 == "3"
true
> '' == 0
true
> 0 == ''
true
> 1 == ''
false
> null == undefined
true
> null === undefined
false
> ' \r\n ' == 0
true
> {} == {}
false
> {} === {}
false
> function f() {
... return
... {
..... a:3
..... }
... }
undefined
> f()
undefined
> typeof NaN
'number'
> typeof []
'object'
> typeof null
'object'
> typeof undefined
'undefined'
> parseInt('2.57')
2
> parseInt('2 is a prime number')
2
> parseInt('015')
15
> parseInt('015', 8)
13
> for( var i in [ 21, 22, 23 ] ) { console.log( i ); };
0
1
2
undefined
> var a = [ 30, 31, 32]
undefined
> a.name = 3
3
> a
[ 30, 31, 32, name: 3 ]