11angular . module ( "typeCoercion" )
2- . factory ( "DataHolderService" , function ( ) {
3- 'use strict' ;
4- function shuffle ( o ) { //v1.0
5- for ( var j , x , i = o . length ; i ; j = Math . floor ( Math . random ( ) * i ) , x = o [ -- i ] , o [ i ] = o [ j ] , o [ j ] = x ) ;
6- return o ;
7- } ;
8- var tasks = shuffle ( [
9- '1 == 1' , // returns true
10- '"1" == 1' , // returns true ("1" converts to 1)
11- '1 == true' , // returns true
12- '0 == false' , // returns true
13- '"" == 0' , // returns true ("" converts to 0)
14- '" " == 0' , // returns true (" " converts to 0)
15- '0 == 1' , // returns false
16- '1 == false' , // returns false
17- '0 == true' , // returns false
18- '0 != false' , // returns false
19- '"" != 0' , // returns false ("" converts to 0)
20- '" " != 0' , // returns false (" " converts to 0)
21- '0 != 1' , // returns true
22- '1 != false' , // returns true
23- '0 != true' , // returns true
24- '1 === 1' , // returns true
25- '"1" === 1' , // returns false ("1" is not converted)
26- '1 === true' , // returns false
27- '0 === false' , // returns false
28- '"" === 0' , // returns false ("" is not converted)
29- '" " === 0' , // returns false (" " is not converted)
30- '0 === 1' , // returns false
31- '1 === false' , // returns false
32- '0 === true' , // returns false
33- 'var x, y;\n' +
34- 'x = {};\n' +
35- 'y = x;\n' +
36- 'x != y //?' , // returns false (refers to same object in memory)
37- 'var x, y;\nx = {};\ny = x;\nx != {} //?' , // returns true (not the same object)
38- 'var x, y;\nx = {};\ny = x;\nx == y //?' , // returns true (refers to same object in memory)
39- 'var x, y;\nx = {};\ny = x;\nx == {} //?' , // returns false (not the same object)
40- 'var x, y;\nx = {};\ny = x;\nx === y //?' , // returns false (not the same object)
41- 'var x, y;\nx = {};\ny = x;\nx === {} //?' ,
42- 'if("")' , // false
43- 'if("5")' , // true
44- 'if(0)' , // false
45- 'if(-1)' , // true
46- 'if(null)' , // false
47- 'if(undefined)' , // false'// returns false (not the same object)
48- 'null == undefined' , // returns true
49- 'null == false' , // returns false
50- 'NaN == NaN' // returns false
51- ] ) ,
52- results = [ ] ;
2+ . factory ( "DataHolderService" , function ( ) {
3+ 'use strict' ;
4+ function shuffle ( o ) { //v1.0
5+ for ( var j , x , i = o . length ; i ; j = Math . floor ( Math . random ( ) * i ) , x = o [ -- i ] , o [ i ] = o [ j ] , o [ j ] = x ) ;
6+ return o ;
7+ } ;
8+ var results = [ ] ;
9+ var tasks = shuffle ( [
10+ '1 == 1' , // returns true
11+ '"1" == 1' , // returns true ("1" converts to 1)
12+ '1 == true' , // returns true
13+ '0 == false' , // returns true
14+ '"" == 0' , // returns true ("" converts to 0)
15+ '" " == 0' , // returns true (" " converts to 0)
16+ '0 == 1' , // returns false
17+ '1 == false' , // returns false
18+ '0 == true' , // returns false
19+ '0 != false' , // returns false
20+ '"" != 0' , // returns false ("" converts to 0)
21+ '" " != 0' , // returns false (" " converts to 0)
22+ '0 != 1' , // returns true
23+ '1 != false' , // returns true
24+ '0 != true' , // returns true
25+ '1 === 1' , // returns true
26+ '"1" === 1' , // returns false ("1" is not converted)
27+ '1 === true' , // returns false
28+ '0 === false' , // returns false
29+ '"" === 0' , // returns false ("" is not converted)
30+ '" " === 0' , // returns false (" " is not converted)
31+ '0 === 1' , // returns false
32+ '1 === false' , // returns false
33+ '0 === true' , // returns false
34+ 'var x, y;\nx = {};\ny = x;\nx != y //?' , // returns false (refers to same object in memory)
35+ 'var x, y;\nx = {};\ny = x;\nx != {} //?' , // returns true (not the same object)
36+ 'var x, y;\nx = {};\ny = x;\nx == y //?' , // returns true (refers to same object in memory)
37+ 'var x, y;\nx = {};\ny = x;\nx == {} //?' , // returns false (not the same object)
38+ 'var x, y;\nx = {};\ny = x;\nx === y //?' , // returns false (not the same object)
39+ 'var x, y;\nx = {};\ny = x;\nx === {} //?' ,
40+ 'if("")' , // false
41+ 'if("5")' , // true
42+ 'if(0)' , // false
43+ 'if(-1)' , // true
44+ 'if(null)' , // false
45+ 'if(undefined)' , // false'// returns false (not the same object)
46+ 'null == undefined' , // returns true
47+ 'null == false' , // returns false
48+ 'NaN == NaN' // returns false
49+ ] ) ;
5350
54- return {
55- getTasks : function ( ) {
56- return tasks ;
57- } ,
58- getResults : function ( ) {
59- return results ;
60- }
61- } ;
51+ return {
52+ getTasks : function ( ) {
53+ return tasks ;
54+ } ,
55+ getResults : function ( ) {
56+ return results ;
57+ }
58+ } ;
6259
63- } ) ;
60+ } ) ;
0 commit comments