Sven Sauleau
Sven Sauleau
@svensauleau
@svensauleau 1
Sven Sauleau @svensauleau @svensauleau 1 Understanding the - - PowerPoint PPT Presentation
Sven Sauleau Sven Sauleau @svensauleau @svensauleau 1 Understanding the Differences Is Accepting @svensauleau 2 Prior art @svensauleau 3 Question 1 switch (0) { 0: case 2 a () ; 3 break ; 4 5 case 1: 6 a () { c on s ol e .
Sven Sauleau
@svensauleau
@svensauleau 1
@svensauleau 2
Prior art
@svensauleau 3
Question
1 switch
(0) {
2
case 0:
3
a () ;
4
break ;
5 6
case 1:
7
function a () { c on s ol e . log ( "foo" ) ; }
8
break ;
9 }
What’s the output?
@svensauleau 4
ECMAScript Spec
1 switch
(0) {
2
case 0:
3
a () ;
4
break ;
5 6
case 1:
7
function a () { c on s ol e . log ( "foo" ) ; }
8
break ;
9 }
@svensauleau 5
Fix
1 switch
(0) {
2
case 0:
3
a () ;
4
break ;
5 6
case 1: { // <--
7
function a () { c on s ol e . log ( "foo" ) ; }
8
break ;
9
} // <--
10 } @svensauleau 6
Question
1 "\n\t\r\n\t\r" == f a l s e
What’s the output?
@svensauleau 7
ECMAScript Spec
1 "\n\t\r\n\t\r" == f a l s e
@svensauleau 8
Question
1 NaN == NaN
What’s the output?
@svensauleau 9
ECMAScript Spec
Unrepresentable/broken value 6.1.6 The Number Type “[...] all NaN values are indistinguishable from each other.” 7.2.15 Strict Equality Comparison “2.a If x is NaN, return false or 2.b If y is NaN, return false.”
@svensauleau 10
Question
1 Math . pow (2 ,
53) + 1 === Math . pow (2 , 53)
What’s the output?
@svensauleau 11
ECMAScript Spec
1 Math . pow (2 ,
53) + 1 === Math . pow (2 , 53)
6.1.6 The Number Type
@svensauleau 12
Question
1 [1 ,
2] == ’1,2’
What’s the output?
@svensauleau 13
ECMAScript Spec
1 [1 ,
2] == ’1,2’
7.2.14 Abstract Equality Comparison “9. If Type(x) is Object and Type(y) is either [...], return the result
and then basically [1, 2].toString().
@svensauleau 14
Question
1 <!−− c on s ol e . log ( "foo" ) −
− >
What’s the output?
@svensauleau 15
ECMAScript Spec
Parsing is defined at B.1.3 HTML-like Comments. Allow browsers that didn’t understand the script tag to degrade gracefully ex Netscape 1
@svensauleau 16
Babel
@svensauleau 17
Question
1 var
t
2 3 t = 0 4 (1 + 1)
What’s the output?
@svensauleau 18
ECMAScript Spec
1 var
t
2 3 t = 0 4 (1 + 1)
11.9 Automatic Semicolon Insertion No ASI because “[...] the parenthesized expression that begins the second line can be interpreted as an argument list for a function call.”
@svensauleau 19
Fix
1 var
t ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
2 3
; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; t = 0 ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
4
; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ( 1 + 1) ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
@svensauleau 20
Clearer Fix
1 var
t ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
2 3 <!
− − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − >
4 5
; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; t = 0 ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
6
; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ( 1 + 1) ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
7 8 <!−−−−−−−−− I
hope that make sense − − − − − − − − − − − >
@svensauleau 21
Question
1 b i t c o i n :
{}{}{}{}{}{}{}{}{}
What’s the output?
@svensauleau 22
Spec
1 b i t c o i n :
{}{}{}{}{}{}{}{}{}
bitcoin is a label forming a LabeledStatement Following by BlockStatements aka the blockchain
@svensauleau 23
Conclusion
Everything is specified! Don’t let me commit on your project
@svensauleau 24