| 
									
										
										
										
											2010-11-05 11:01:37 -06:00
										 |  |  | // Firefox was tested using persevere's global-es5 for es5 emulation
 | 
					
						
							| 
									
										
										
										
											2010-11-05 10:50:17 -06:00
										 |  |  | (function () { | 
					
						
							| 
									
										
										
										
											2010-11-30 01:14:36 -07:00
										 |  |  |   require('../lib/remedial'); | 
					
						
							| 
									
										
										
										
											2010-11-05 10:50:17 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |   a = []; | 
					
						
							|  |  |  |   a[2] = 27; | 
					
						
							|  |  |  |   console.log(a); | 
					
						
							|  |  |  |   // Expected: [undefined, undefined, 27];
 | 
					
						
							|  |  |  |   // Node/V8: [ 27 ];
 | 
					
						
							|  |  |  |   // FF3: [undefined, undefined, 27];
 | 
					
						
							|  |  |  |   console.log(a.length); | 
					
						
							|  |  |  |   // 3
 | 
					
						
							|  |  |  |   console.log(typeOf(a)); | 
					
						
							|  |  |  |   // array
 | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   b = Object.create([]); | 
					
						
							|  |  |  |   b[2] = 27; | 
					
						
							|  |  |  |   console.log(b); | 
					
						
							|  |  |  |   // Expected: [undefined, undefined, 27];
 | 
					
						
							|  |  |  |   // Node/V8: [ 27 ]
 | 
					
						
							|  |  |  |   console.log(b.length); | 
					
						
							|  |  |  |   // Expected: 3
 | 
					
						
							|  |  |  |   // Node/V8/FF: 0
 | 
					
						
							|  |  |  |   console.log(typeOf(b)); | 
					
						
							| 
									
										
										
										
											2010-11-30 01:59:29 -07:00
										 |  |  |   // Expected: Object (with Flanagan / Miller device or jQuery's type)
 | 
					
						
							| 
									
										
										
										
											2010-11-30 01:14:36 -07:00
										 |  |  |   // Node/V8/FF: array (with Crockford's original)
 | 
					
						
							| 
									
										
										
										
											2010-11-05 10:50:17 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   c = Object.create([]); | 
					
						
							|  |  |  |   c.push(); | 
					
						
							|  |  |  |   c.push(); | 
					
						
							|  |  |  |   c.push(27); | 
					
						
							|  |  |  |   console.log(c); | 
					
						
							|  |  |  |   // Expected: [undefined, undefined, 27]
 | 
					
						
							|  |  |  |   // Node: [ 27, length: 1 ]
 | 
					
						
							|  |  |  |   // FF: []
 | 
					
						
							|  |  |  |   console.log(c.length); | 
					
						
							|  |  |  |   // Expected: 3
 | 
					
						
							|  |  |  |   // Node/V8/FF: 1
 | 
					
						
							|  |  |  |   console.log(typeOf(c)); | 
					
						
							| 
									
										
										
										
											2010-11-30 01:14:36 -07:00
										 |  |  |   // Expected: object
 | 
					
						
							| 
									
										
										
										
											2010-11-05 10:50:17 -06:00
										 |  |  |   // Node/V8/FF: object
 | 
					
						
							| 
									
										
										
										
											2010-11-05 10:57:41 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   d = Object.create(Array); | 
					
						
							|  |  |  |   // FF: Error: typeof prototype[function] != 'object'
 | 
					
						
							|  |  |  |   d[2] = 27; | 
					
						
							|  |  |  |   console.log(d); | 
					
						
							|  |  |  |   // Expected: [undefined, undefined, 27];
 | 
					
						
							|  |  |  |   // Node/V8: { '2': 27 }
 | 
					
						
							|  |  |  |   console.log(d.length); | 
					
						
							|  |  |  |   // Expected: 3
 | 
					
						
							|  |  |  |   // Node/V8/FF: 1
 | 
					
						
							|  |  |  |   console.log(typeOf(d)); | 
					
						
							| 
									
										
										
										
											2010-11-30 01:14:36 -07:00
										 |  |  |   // Expected: object
 | 
					
						
							| 
									
										
										
										
											2010-11-05 10:57:41 -06:00
										 |  |  |   // Node/V8: object
 | 
					
						
							| 
									
										
										
										
											2010-11-05 10:50:17 -06:00
										 |  |  | }()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* | 
					
						
							|  |  |  |   Exact Node Output: | 
					
						
							|  |  |  |   [ 27 ] | 
					
						
							|  |  |  |   3 | 
					
						
							|  |  |  |   array | 
					
						
							|  |  |  |   [ 27 ] | 
					
						
							|  |  |  |   0 | 
					
						
							|  |  |  |   array | 
					
						
							|  |  |  |   [ 27, length: 1 ] | 
					
						
							|  |  |  |   1 | 
					
						
							|  |  |  |   object | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Exact FF (firebug) Output (expanded): | 
					
						
							|  |  |  |   [undefined, undefined, 27] | 
					
						
							|  |  |  |     >   2         27 | 
					
						
							|  |  |  |   3 | 
					
						
							|  |  |  |   array | 
					
						
							|  |  |  |   [] | 
					
						
							|  |  |  |     >   2         27 | 
					
						
							|  |  |  |   0 | 
					
						
							|  |  |  |   array | 
					
						
							|  |  |  |   [27] | 
					
						
							|  |  |  |     >   0         27 | 
					
						
							|  |  |  |         length    1 | 
					
						
							|  |  |  |   1 | 
					
						
							|  |  |  |   object | 
					
						
							|  |  |  | */ |