Labels
Semicolons
Coercions
Comparisons
Inequalities
Calculus
Conditional statements
Destructuring assignment
void
operator
typeof
operator
,
operator
try-catch
statement
Hoisting
Scopes & Closures & Hoisting
Context
delete
operator
...
operator
instanceof
operator
Template literals
Object
Function
Default parameters
arguments
class
GeneratorFunction
Promise
AsyncFunction
Reflect
Proxy
Array
Date
RegExp
Symbol
String
Number
Boolean
Math
Window
Event loop
eval
method
with
operator
Miscellaneous
vars: var vars = vars ;
vars ;
var foo = { } ;
var bar = 1 ;
foo: {
bar: 2 ;
baz: ++ bar ;
} ;
foo . baz + foo . bar + bar ;
a: b: c: d: e: f: g: 1 , 2 , 3 , 4 , 5 ;
( printing => {
printing: {
console . log ( 1 ) ;
if ( ! printing ) {
break printing;
}
console . log ( 2 ) ;
} ;
console . log ( 3 ) ;
} ) ( false ) ;
Back to top
var foo = [ ] // Missing semicolon!
( new Date ) . getTime ( ) ;
! function ( ) { console . log ( 'Awesome' ) ; } ( ) // Missing semicolon!
! function ( ) { console . log ( 'JS' ) ; } ( ) ;
var [ foo , bar , baz ] = [ 1 , 2 , 3 ] ;
foo = bar // Missing semicolon!
++ baz
[ foo , bar , baz ] ;
function foo ( ) {
return // Missing semicolon!
'Awesome JS' ;
}
foo ( ) === 'Awesome JS' ;
var bar = 'bar' // Missing semicolon!
/ JS / g . exec ( 'Awesome JS' ) ;
Back to top
[ ] + [ ] + 'foo' . split ( '' ) ;
[ 1 , 2 , [ 3 , 4 ] ] + [ [ 5 , 6 ] , 7 , 8 ] ;
[ 3 + NaN + true ] + [ 10 / ( 8 * null ) - 1 ] ;
Back to top
var x = true ;
var y = false ;
x != y === ! ( x == y ) ;
! ! 'false' == ! ! 'true' ;
! ! 'false' === ! ! 'true' ;
1 + 2 + '3' == 1 + '2' + 3 ;
Back to top
Back to top
0.1 + ( 0.2 + 0.3 ) == ( 0.1 + 0.2 ) + 0.3 ;
( 0.2 + 0.4 ) / 1 == ( 0.1 + 0.2 ) * 2 ;
9999999999999999 === 1e16 ;
var x = 5 ;
var y = 10 ;
var z = x ++ + y ;
[ x , y , z ] ;
~ ~ + '2.9' - 1 == ( '2.9' >> 0 ) - 1 ;
( 0.00008 ) . toFixed ( 3 ) === 0 ;
parseFloat ( '\t\v\r12.34\n ' ) ;
Back to top
var x , y ;
x = ( y = 0 ) && ( y = 1 ) ;
[ x , y ] ;
var x = 1 ;
if ( false )
x = 3 ;
x = 4 ;
x ;
var foo = NaN ;
switch ( foo ) {
case NaN :
console . log ( 'NaN' ) ;
break ;
default :
console . log ( 'default' ) ;
}
var foo = { } ;
switch ( foo ) {
case { } :
console . log ( 'object' ) ;
break ;
default :
console . log ( 'default' ) ;
}
Back to top
var [ x , x , x , x ] = 'JS is awesome language' . split ( ' ' ) ;
x ;
( { x, y } = { x : 5 , y : 6 , x : 7 } ) ;
var { x, y } = { x : x , y : y } ;
[ x , y ] ;
var x , { x : y = 1 } = { x } ;
[ x , y ] ;
var o1 = { a : 1 } ,
o2 = { b : 2 } ,
o3 = { c : 3 }
[ o1 , o2 , o3 ] = [ o3 , o2 , o1 ] ;
o3 ;
Back to top
void function ( ) { return 'foo' ; } ( ) ;
Back to top
typeof { null : null } . null ;
typeof setTimeout ( ( ) => { } , 0 ) ;
var y = 1 , x = y = typeof x ;
x ;
var x = [ typeof x , typeof y ] [ 1 ] ;
typeof typeof x ;
Back to top
var x = 0 ;
var y = ( x ++ , 99 ) ;
[ x , y ] ;
if ( 9 , 0 ) console . log ( 'ok' ) ;
[ true , false ] [ + true , + false ] ;
var smth = ( 45 , 87 ) > ( 195 , 3 ) ? 'bar' : ( 54 , 65 ) > ( 1 , 0 ) ? '' : 'baz' ;
alert ( '1' , alert ( '2' , alert ( '3' ) ) ) ;
var f = ( function f ( ) { return '1' } , function g ( ) { return 2 } ) ( ) ;
typeof f ;
if ( ( 1 , true ) && ( 2 , false ) || ( 3 , false ) && ( 4 , true ) || ( 5 , true ) ) {
console . log ( 'if' ) ;
} else {
console . log ( 'else' ) ;
}
alert ( '2' ,
foo = ( x ) => alert ( x ) ,
foo ( '1' )
) ,
foo ( '3' ) ;
Back to top
( ( ) => {
try {
return 'try' ;
} finally {
console . log ( 'finally' ) ;
}
} ) ( ) ;
var foo = ( ) => {
var o = { foo : 24 } ;
window . bar = ( ) => {
return o ;
} ;
try {
return o ;
} finally {
o = null ;
}
} ;
foo ( ) ; // => ?
bar ( ) ; // => ?
try {
setTimeout ( function ( ) {
throw new Error ( )
} , 1000 ) ;
} catch ( err ) { }
try {
try {
throw new Error ( 'try' ) ;
} catch ( err ) {
console . error ( 'inner' , err . message ) ;
throw err ;
} finally {
console . log ( 'finally' ) ;
}
} catch ( err ) {
console . error ( 'outer' , err . message ) ;
}
( ( ) => {
label: try {
return 0 ;
} finally {
break label;
return 1 ;
}
return 2 ;
} ) ( ) ;
( ( ) => {
try {
throw new Error ( 'try' )
} catch ( err ) {
throw err ;
} finally {
throw new Error ( 'finally' ) ;
}
} ) ( ) ;
Back to top
var bar ;
f ( ) ;
function f ( ) {
return bar ;
}
var bar = 2410 ;
( function ( ) {
console . log ( x ) ;
console . log ( f ( ) ) ;
var x = 1 ;
function f ( ) {
return 2 ;
}
} ) ( ) ;
function f ( x ) {
return x * 2 ;
}
var f ;
typeof f ;
Back to top
Scopes & Closures & Hoisting
var x = 1 ;
{
var x = 2 ;
}
x ;
if ( ! ( 'y' in window ) ) {
var y = 1 ;
}
y ;
( function ( ) {
var x = x = 3 ;
} ) ( ) ;
[ typeof x , typeof y ] ;
var foo = function bar ( ) {
return 'bar' ;
}
typeof bar ( ) ;
var foo = 1 ;
function bar ( ) {
foo = 10 ;
return ;
function foo ( ) { } ;
}
bar ( ) ;
foo ;
x = 1 ;
( ( ) => {
return x ;
var x = 2 ;
} ) ( ) ;
var x = 1 ;
if ( function f ( ) { } ) {
x += typeof f ;
}
x ;
( function f ( ) {
function f ( ) { return 1 ; }
return f ( ) ;
function f ( ) { return 2 ; }
} ) ( ) ;
for ( var i = 0 ; i < 10 ; i ++ ) {
setTimeout ( ( ) => alert ( i ) , 100 ) ;
}
var foo = 11 ;
function bar ( ) {
return foo ;
foo = 10 ;
function foo ( ) { } ;
var foo = '12' ;
}
typeof bar ( ) ;
var foo = 1 ,
var bar = function foo ( x ) {
x && foo ( -- x ) ;
} ;
foo ;
( function ( ) {
var foo = 'x' ;
( function ( foo ) {
foo = 'y' ;
} ) ( foo ) ;
return foo ;
} ) ( ) ;
( function f ( f ) {
return typeof f ( ) ;
} ) ( ( ) => 1 ) ;
function f ( ) {
var x = 5 ;
return new Function ( 'y' , 'return x + y' ) ;
}
f ( ) ( 1 ) ;
var x = 1 ;
function f ( ) {
var x = 2 ;
return new Function ( '' , 'return x' ) ;
}
f ( ) ( ) ;
Back to top
function f ( ) {
alert ( this ) ;
}
f . call ( null ) ;
function f ( ) {
return this ;
}
f . call ( f ) ;
( function ( ) {
var f = function ( ) {
return this * 2 ;
} ;
return [
f . call ( undefined ) ,
f . call ( null ) ,
f . call ( 1 )
] ;
} ) ( ) ;
var user = {
name : 'Alex' ,
_user : this
} ;
user . _user . name ;
var foo = {
bar ( ) { return this . baz } ,
baz : 1
} ;
typeof ( f = foo . bar ) ( ) ;
( function ( ) {
'use strict'
var x = 10 ;
var foo = {
x : 20 ,
bar ( ) {
var x = 30 ;
return this . x ;
}
} ;
return [
foo . bar ( ) ,
( foo . bar ) ( ) ,
( foo . bar = foo . bar ) ( ) ,
( foo . bar , foo . bar ) ( ) ,
( foo . baz || foo . bar ) ( )
] ;
} ) ( ) ;
var foo = {
bar : function ( ) { return this === foo } ,
baz : ( ) => this === foo
} ;
foo . bar ( ) === foo . baz ( ) ;
var foo = {
bar : 'bar' ,
baz : ! ( function ( ) {
console . log ( this . bar ) ;
} ) ( )
} ;
foo . baz ;
( function ( ) {
'use strict' ;
const g1 = ( function ( ) { return this || ( 1 , eval ) ( 'this' ) } ) ( ) ;
const g2 = ( function ( ) { return this } ) ( ) ;
return g1 === g2 ;
} ( ) ) ;
Back to top
var numbers = [ 2 , 3 , 5 , 7 , 11 , 13 ] ;
delete numbers [ 3 ] ;
numbers . length ;
function foo ( ) { } ;
delete foo . length ;
typeof foo . length ;
var Person = function ( ) { } ;
Person . prototype . type = 'person' ;
var admin = new Person ( ) ;
delete admin . type ;
admin . type ;
delete delete window . document ;
( function ( ) {
x = 1 ;
window . y = 2 ;
this . z = 3 ;
var w = 4 ;
delete x ;
delete y ;
delete z ;
delete w ;
return [ typeof x , typeof y , typeof z , typeof w ] ;
} ) ( ) ;
( x => {
delete x ;
return x ;
} ) ( 1 ) ;
var x = 1 ;
y = 1 ;
( function ( ) {
return ( delete window . x ) === ( delete window . y ) ;
} ) ( ) ;
Back to top
var foo = [ ...[ , , 24 ] ] ;
[ 0 in foo , 1 in foo , 2 in foo ] ;
Back to top
function A ( ) { } ;
function B ( ) { } ;
A . prototype = B . prototype = { } ;
var a = new A ( ) ;
a instanceof B ;
function A ( ) { } ;
var a = new A ( ) ;
A . prototype = { } ;
a instanceof A ;
function A ( ) { } ;
function B ( ) { } ;
B . prototype = Object . create ( A . prototype ) ;
var b = new B ( ) ;
b instanceof A ;
function f ( ) { return f ; }
new f ( ) instanceof f ;
Back to top
`use strict` ;
this == null ;
typeof `${ { Object} } ` . prototype
var foo = { `hello world` : 24 } ;
Back to top
Object instanceof Function ;
Object . prototype . toString . call ( ) ;
Object . prototype . toString . call ( Object ) ;
Object . assign ( { } , 'function' ) ;
var foo = 'abc' ;
var bar = Object ( foo ) ;
Object . prototype . toString . call ( bar ) ;
Object . freeze ( window ) ;
var didItWork = true ;
didItWork ;
( { 'toString' : null } ) . propertyIsEnumerable ( 'toString' ) ;
var obj = {
'' : ''
} ;
obj [ '' ] ;
var obj = {
1 : 'foo'
} ;
obj [ 1 ] == obj [ [ 1 ] ] ;
obj [ [ 1 ] ] == obj [ '1' ] ;
'foo' . someProperty = 17 ;
'foo' . someProperty ;
( function ( ) {
var foo = { } ;
var bar = { } ;
var map = { } ;
map [ foo ] = 'foo' ;
map [ bar ] = 'bar' ;
return map [ foo ] ;
} ) ( ) ;
100 [ 'toString' ] [ 'length' ] ;
{ valueOf : ( ) => true } == '1.0e0' ;
var foo = {
toString : ( ) => '[object Foo]' ,
valueOf : ( ) => 2410
} ;
'object: ' + foo ;
var x = 1 ;
var y = { toString : ( ) => '1' } ;
var z = 1 ;
x + y + z ;
var foo = { x : 1 } ;
foo . y = foo = { x : 2 } ;
foo . y ;
var t = true ;
var obj = ( { [ t ] : t } ) ;
obj ;
var t = true ;
var obj = ( { [ `${ t } ` ] : t , [ t ] : t } ) ;
obj ;
( '__proto__' ) . __proto__ . __proto__ . __proto__ ;
var proto = {
x : ( ) => 'x'
}
var foo = new Object ( proto ) ;
var bar = new Object ( proto ) ;
foo === bar ;
Object . create ( null ) instanceof Object ;
var bar = { bar : 'bar' } ;
function foo ( ) { }
foo . prototype = bar ;
[ bar instanceof foo , Object . create ( bar ) instanceof foo ] ;
Object . prototype . isPrototypeOf ( window ) ;
var foo = { __proto__ : null } ;
Object . getPrototypeOf ( foo ) === null ;
var __proto__ = 'bar' ;
var foo = { __proto__ } ;
Object . getPrototypeOf ( foo ) === Object . prototype ;
Back to top
typeof Function ;
Function instanceof Function ;
Function instanceof Object ;
typeof Function . prototype ;
Function . prototype instanceof Function ;
Function . prototype . isPrototypeOf ( Function ) ;
Function . prototype . prototype ;
Function . prototype === Function ;
Function . prototype . constructor === Function ;
( function ( x , y ) { } ) . length ;
( function ( foo ) {
return typeof foo . bar ;
} ) ( { foo : { bar : 1 } } ) ;
var f = ( ) => { x : 1 } ;
f ( ) ;
function f ( ) { } ;
f . bind ( this ) . name ;
var f = function ( ) { } ;
var g = f . bind ( ) ;
g . prototype ;
function f ( x , y ) {
return x + y ;
}
f . bind ( 1 ) ( ) ;
function f ( ) {
return this . value ;
}
f . bind ( { value : 1 } ) . call ( { value : 2 } ) ;
var f = ( ) => this ;
var g = function ( ) { return this } . bind ( this ) ;
f ( ) === g ( ) ;
function f ( ) { }
var fBind = f . bind ( { } ) ;
var obj = new f ( ) ;
[ obj instanceof f , obj instanceof fBind ] ;
function foo ( ) {
return Function . bind ( null , 'console.log(bar);' ) ;
}
var bar = 1 ;
( function ( ) {
var bar = 2 ;
foo ( ) ( ) ( ) ;
} ) ( ) ;
( function ( ) {
if ( false ) {
let f = { g ( ) => 1 } ;
}
return typeof f ;
} ) ( ) ;
var foo = 2410 ;
var bar = [ 'a' , 'b' ] ;
var baz = { first : true } ;
function f ( x , y , z ) {
x = 3 ;
y . push ( 'c' ) ;
y = [ 'c' ] ;
z . first = false ;
z = true ;
}
f ( foo , bar , baz ) ;
[ foo , bar , baz . first ] ;
function f ( name ) {
this . name = name ;
}
var name = 'foo' ;
var person = f ( 'bar' ) ;
[ name , person ] ;
var x = 0 ;
function f ( ) {
x ++ ;
this . x = x ;
return f ;
}
var foo = new new f ;
foo . x ;
var c = 'constructor' ;
c [ c ] [ c ] ( 'console.log(c)' ) ( ) ;
var f = Function . prototype . call ;
f ( ) ;
console . log . call . call . call . call . call . apply ( x => x , [ 1 , 2 ] ) ;
Back to top
function f ( x = 24 , y = 10 ) {
return x + y ;
}
foo ( undefined , 20 ) ;
foo ( null , null ) ;
function g ( x , y = 24 , z = 10 ) {
return x + y + z ;
}
g ( 1 , , 2 ) ;
var bar = 1 ;
function f ( bar = bar ) {
return bar ;
}
f ( ) ;
var x = 1 ;
function f ( y = function ( ) { return x ; } ) {
var x = 2 ;
return y ( ) ;
}
f ( ) ;
function f ( x , y = function ( ) { return x ; } ) {
console . log ( x ) ;
var x = 1 ;
console . log ( y ( ) ) ;
}
f ( 2 ) ;
function f ( x , y = function ( ) { console . log ( x ) ; x = 1 ; } ) {
var x ;
console . log ( x ) ;
x = 2 ;
y ( ) ;
console . log ( x ) ;
}
f ( 3 ) ;
Back to top
( function ( ) {
return typeof arguments ;
} ) ( ) ;
( function ( ) {
return arguments . toString ( ) ;
} ) ( ) ;
( function ( ) {
console . log (
arguments . constructor === { } . constructor ,
arguments . constructor === [ ] . constructor
) ;
} ) ( ) ;
( function ( ) {
var arguments ;
return arguments [ 0 ] ;
} ) ( 200 ) ;
function f ( x , y , z ) {
arguments [ 2 ] = 10 ;
return z ;
}
f ( 1 , 2 , 3 ) ;
( ( ) => arguments . toString ( ) ) ( ) ;
function f ( x , y ) {
arguments [ 2 ] = 5 ;
return y ;
}
f ( 1 ) ;
function f ( foo , bar , baz ) {
return Array . from ( arguments ) ;
}
f ( ...[ 'foo' , , 'bar' ] ) ;
var g = function ( ) {
return arguments ;
} ;
g ( ) == g ( ) ;
Back to top
var Foo = class { } ;
class Foo { } ;
class AwesomeJS extends null { } ;
new AwesomeJS ;
typeof ( new ( class F extends ( String , Array ) { } ) ) . substring ;
typeof ( new ( class { class ( ) { } } ) ) ;
( function ( ) {
let f = this ? class g { } : class h { } ;
return [
typeof f ,
typeof h
] ;
} ) ( ) ;
class A {
foo ( ) {
console . log ( 'A.foo' ) ;
}
}
class B extends A {
foo ( ) {
super . foo ( ) ;
}
}
class C {
foo ( ) {
console . log ( 'C.foo' ) ;
}
}
var D = {
foo : B . prototype . foo ,
} ;
Object . setPrototypeOf ( B , C . constructor ) ;
D . foo ( ) ;
Back to top
function * g ( ) {
yield 'foo' ;
}
g [ Symbol . toStringTag ] === g ( ) [ Symbol . toStringTag ] ;
function * g ( ) {
yield 'foo' ;
yield yield 'bar' ;
yield yield yield 'baz' ;
}
var gen = g ( ) ;
[ ...gen ] ;
( function * f ( ) { yield f } ) ( ) . next ( )
Back to top
typeof Promise . resolve ( 2410 ) ;
Promise . reject ( Promise . resolve ( ) ) ;
new Promise ( ( resolve , reject ) => resolve ( 24 ) )
. then ( ( res ) => console . log ( res ) )
. then ( ( res ) => console . log ( res ) ) ;
Promise . resolve ( 'foo' )
. then ( Promise . resolve ( 'bar' ) )
. then ( ( res ) => console . log ( res ) ) ;
Promise . resolve ( 'foo' )
. then ( ( res ) => Promise . resolve ( 'bar' ) )
. then ( ( res ) => console . log ( res ) ) ;
Promise . resolve ( 2 )
. then ( 3 )
. then ( ( res ) => console . log ( res ) ) ;
Promise . resolve ( { x : 24 } )
. then ( ( res ) => delete res . x )
. then ( ( res ) => console . log ( res . x ) ) ;
Promise . resolve ( 2410 ) . then (
( res ) => { throw new Error ( res ) } ,
( err ) => { try { } catch ( err ) { } }
) ;
Promise . reject ( 24 )
. then ( null , null )
. then ( null , ( reason ) => console . log ( reason ) ) ;
Promise . reject ( 24 )
. then ( 10 , null )
. then ( null , ( reason ) => console . log ( reason ) ) ;
Promise . reject ( 24 )
. then ( null , 10 )
. then ( null , ( reason ) => console . log ( reason ) ) ;
Promise . resolve ( 24 )
. then ( null , null )
. then ( ( res ) => console . log ( res ) , null ) ;
Promise . resolve ( 24 )
. then ( null , 10 )
. then ( ( res ) => console . log ( res ) , null ) ;
Promise . resolve ( 24 )
. then ( 10 , null )
. then ( ( res ) => console . log ( res ) , null ) ;
Back to top
async function f ( x ) {
return x * x ;
}
f ( 2 ) === 4 ;
var y = 2 ;
async function f ( x = await y ) {
return x * x ;
}
f ( ) ;
( ( ) => {
'use strict' ;
async function eval ( x , y ) {
await x * y ;
}
eval ( 1 , 2 ) ;
} ) ( ) ;
async function f ( x ) {
return await x * ( await x ) ;
}
f ( 2 ) . then ( res => console . log ( res ) ) ;
async function User ( firstname , lastname ) {
this . firstname = await firstname ;
this . lastname = await lastname ;
}
var user = new User ( 'John' , 'Doe' ) ;
( async function ( ) { } ) . __proto__ . __proto__ == ( function ( ) { } ) . __proto__ ;
Back to top
Reflect . get ( Reflect , Reflect . get ( Reflect , 'get' ) . name ) ;
Reflect . setPrototypeOf ( Reflect , Array . prototype ) ;
typeof Reflect . slice ;
Reflect . preventExtensions ( Reflect ) ;
Reflect . isExtensible ( Reflect ) ;
Back to top
var proxy = new Proxy ( { } , { } ) ;
proxy instanceof Proxy ;
( ( ) => {
Proxy . prototype = null ;
class P extends Proxy {
constructor ( ) {
super ( window , { } ) ;
this . foo = 'foo' ;
}
} ;
new P ;
console . log ( window . foo ) ;
} ) ( ) ;
( ( ) => {
Proxy . prototype = null ;
class P extends Proxy {
constructor ( ) {
super ( window , {
getPrototypeOf ( ) { return P . prototype }
} ) ;
}
} ;
console . log ( ( new P ) instanceof P === true ) ;
} ) ( ) ;
Back to top
var arr = [ ] ;
arr [ 1 ] = 1 ;
arr [ 24 ] = 24 ;
arr . length ;
var arr = [ ] ;
var i = 3 ;
arr [ -- i ] = ++ i ;
arr ;
new Array ( [ ] , null , undefined , null ) == ',,,' ;
var arr = new Array ( 3 ) ;
arr . map ( ( value , index ) => index ) ;
[ 1 , 2 , 3 , 4 , 5 ] [ 0. . toString ( ) . length ] ;
var arr = [ 2 , 3 , 5 , 7 , 11 ] ;
arr . indexOf ( 7 , 2 ) ;
arr . indexOf ( 2 , - 3 ) ;
Array ( 4 ) . join ( 'js!' - 4 ) ;
Array ( 5 ) . join ( ',' ) . length ;
[ ] . fill . call ( { length : 3 } , 4 ) ;
var arr = [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] ;
arr . slice ( ) ;
arr . slice ( - 2 ) ;
arr . slice ( 3 , - 6 ) ;
[ 1 , 2 , 3 ] . slice ( 0 , null ) ;
Array ( 3 ) . map ( item => 'x' ) ;
Array . apply ( null , new Array ( 4 ) ) . map ( ( el , i ) => i ) ;
Array . apply ( null , { length : 3 } ) ;
[ ...new Set ( [ 1 , 1 , 2 , 3 , 5 , 8 , 13 ] ) ] ;
var arr = [ 1 , 2 , 3 ] ;
var pushResult = arr . push ( 4 , 5 , 6 ) ;
[ pushResult , arr ] ;
var arr = [ undefined , , true ] ;
arr . filter ( ( ) => true ) ;
var arr = new Array ( 2 ) ;
var i = 0 ;
arr . forEach ( ( ) => i ++ ) ;
i ;
var arr = [ 80 , 9 , 34 , 23 , 5 , 1 ] ;
arr . sort ( ) ; // => ?
new Array ( 10 ) . map ( ( el , i ) => i + 1 ) ;
var bag = new Array ( 3 ) . fill ( [ ] ) ;
bag [ 0 ] . push ( 1 ) ;
bag [ 1 ] . push ( 1 ) ;
bag ; // => ?
Array . isArray ( {
constructor : Array ,
length : 0 ,
__proto__ : Array . prototype ,
} ) ;
Array . prototype . push ( 1 , 2 , 3 ) ;
Array . prototype [ 1 ] = 'foo' ;
var arr = [ undefined , , ] ;
0 in arr ; // => ?
1 in arr ; // => ?
arr . hasOwnProperty ( 1 ) ; // => ?
Back to top
'2016/12/31' == new Date ( '2016/12/31' ) ;
typeof ( new Date ( ) + new Date ( ) ) ;
new Date ( - 666 ) . getUTCMonth ( ) ;
var f = Date . bind . call ( Date , 2000 , 0 , 1 ) ;
var g = Function . bind . call ( Date , null , 2000 , 0 , 1 ) ;
new f ( ) . toString ( ) === new g ( ) . toString ( ) ;
Back to top
RegExp . prototype . toString = function ( ) {
return this . source ;
}
/ 3 / 3 / - / 1 / ;
( ( ) => {
class CustomRegExp extends RegExp {
constructor ( ) {
super ( ) ;
}
}
return new CustomRegExp ;
} ) ( ) ;
'foobar' . replace ( / ^ / , "$'" ) ;
/ f o o .b a r / . test ( 'foo\nbar' ) ;
'test' . split ( / (?: ) / , - 1 ) ;
typeof ( / ( ) ? ?/ ) . exec ( '' ) [ 1 ] ;
/ ^ $ ^ $ ^ $ ^ $ ^ $ ^ $ $ $ $ ^ ^ ^ / . test ( '' ) ;
new RegExp ( [ ] . join ( '|' ) ) ;
var foo = / [ / + ' j a v a s c r i p t ' [ 0 ] + ' / //';
foo ;
var bar = / \[ / + 'javascript' [ 0 ] + '///' ;
bar ;
Back to top
Symbol ( 'foo' ) === Symbol ( 'foo' ) ;
class MySymbol extends Symbol {
constructor ( ) {
super ( ) ;
}
}
var symbol = new MySymbol ( ) ;
Symbol . for ( 'bar' ) === Symbol . for ( 'bar' ) ;
Symbol . keyFor ( Symbol . iterator ) ;
var obj = {
[ Symbol ( 'foo' ) ] : 'foo' ,
[ Symbol ( 'bar' ) ] : 'bar'
} ;
Object . keys ( obj ) ;
var obj = { } ;
obj [ Symbol ( 'foo' ) ] = true ;
obj [ Symbol ( 'foo' ) ] = false ;
Object . getOwnPropertySymbols ( obj ) . length ;
Back to top
'foo' == new function ( ) { return String ( 'foo' ) } ;
'foo' [ - 1 ] == 'foo' . charAt ( - 1 ) ;
'foo' . charAt ( 1 ) === 'foo' . substring ( 1 , 2 ) ;
Back to top
Number . MAX_VALUE > 0 ;
Number . MIN_VALUE > 0 ;
Number . isNaN ( 'NaN' ) === window . isNaN ( 'NaN' ) ;
Number ( '0.' ) === Number ( '.0' ) ;
Number . prototype . compare = function ( value ) {
return this === value ;
} ;
Number ( 123 ) . compare ( 123 ) ;
Number . prototype . toString = function ( ) {
return typeof this ;
} ;
( 4 ) . toString ( ) ;
Back to top
Boolean ( 'true' ) === true ;
if ( new Boolean ( false ) ) {
console . log ( 'Awesome JS' ) ;
}
new Boolean ( '' ) . valueOf ( ) ;
new Boolean ( false ) . valueOf ( ) === false ;
Back to top
Math . ceil ( 5.01 ) === - Math . floor ( - 5.01 ) ;
Math . pow ( 2 , 53 ) === Math . pow ( 2 , 53 ) + 1 ;
Back to top
typeof window ;
typeof Window ;
Object . getPrototypeOf ( window ) === Window ;
Window . constructor === Function ;
Window . prototype . constructor === Window ;
( ( ) => {
console . log ( window ) ;
var window = window ;
} ) ( ) ;
Back to top
setTimeout ( ( ) => console . log ( 1 ) , 1 ) ;
setTimeout ( ( ) => console . log ( 2 ) , 1000 ) ;
setTimeout ( ( ) => console . log ( 3 ) , 0 ) ;
console . log ( 4 ) ;
setTimeout ( ( ) => {
console . log ( 1 ) ;
setTimeout ( ( ) => console . log ( 2 ) , 0 ) ;
} , 500 ) ;
setTimeout ( ( ) => {
setTimeout ( ( ) => console . log ( 3 ) , 500 ) ;
} , 250 ) ;
new Promise ( ( resolve , reject ) => {
console . log ( 1 ) ;
resolve ( ) ;
} ) . then ( ( ) => {
console . log ( 2 ) ;
} ) ;
console . log ( 3 ) ;
setTimeout ( ( ) => {
console . log ( 1 ) ;
} , 300 ) ;
Promise . resolve ( )
. then ( ( ) => console . log ( 2 ) ) ;
console . log ( 3 ) ;
setTimeout ( ( ) => {
console . log ( 1 ) ;
} , 0 ) ;
Promise . resolve ( 2 )
. then ( ( res ) => {
console . log ( res ) ;
setTimeout ( ( ) => {
console . log ( 3 ) ;
} , 0 ) ;
return Promise . resolve ( 4 ) ;
} )
. then ( ( res ) => {
console . log ( res ) ;
} ) ;
async function f ( ) {
console . log ( await new Promise ( resolve => {
setTimeout ( ( ) => resolve ( 2 ) , 0 ) ;
} ) ) ;
}
console . log ( 1 ) ;
f ( ) ;
console . log ( 3 ) ;
// Node.js
setTimeout ( ( ) => {
console . log ( 1 ) ;
} , 1000 ) ;
process . nextTick ( ( ) => {
console . log ( 2 ) ;
} ) ;
console . log ( 3 ) ;
// Node.js
process . nextTick ( ( ) => {
console . log ( 1 ) ;
while ( true ) { }
} ) ;
process . nextTick ( ( ) => {
console . log ( 2 ) ;
} ) ;
Back to top
function foo ( ) {
return eval . bind ( null , '(function() { return bar; })' ) ;
}
var bar = 1 ;
( function ( ) {
var bar = 2 ;
foo ( ) ( ) ( ) ; // => ?
} ) ( ) ;
function foo ( ) {
return '(function() { return bar; })' ;
}
var bar = 1 ;
( function ( ) {
var bar = 2 ;
eval ( foo ( ) ) ( ) ; // => ?
} ) ( ) ;
Back to top
var a = 1 ;
var obj = {
b : 2
} ;
with ( obj ) {
var b ;
console . log ( a + b ) ; // => ?
}
with ( { a : 1 } ) {
a = 2 ,
b = 3
}
[ window . a , window . b ] ;
with ( function ( x , undefined ) { } ) {
length ; // => ?
}
( {
x : 10 ,
foo ( ) {
function bar ( ) {
console . log ( x ) ; // => ?
console . log ( y ) ; // => ?
console . log ( this . x ) ; // => ?
}
with ( this ) {
var x = 20 ;
var y = 30 ;
bar . call ( this ) ;
}
}
} ) . foo ( ) ;
var foo = { bar : 'baz' && 'foobarbaz' } ;
with ( foo ) var bar = eval ( 'bar, 24' ) ;
foo . bar ;
Back to top
( ! [ ] + [ ] ) [ + [ ] ] + ( ! [ ] + [ ] ) [ + ! + [ ] ] + ( [ ! [ ] ] + [ ] [ [ ] ] ) [ + ! + [ ] + [ + [ ] ] ] + ( ! [ ] + [ ] ) [ ! + [ ] + ! + [ ] ] ;
( { [ { } ] :{ [ { } ] :{ } } } ) [ { } ] [ { } ] ;
( function pewpew ( Infinity , length , __proto__ ) {
return [ , , ~ 0. [ 0 | 0 ] ] [ pewpew . __proto__ . length && Infinity ,
- ~ String ( this ) . length >> __proto__ ] << ( 0. === .0 ) + Infinity ;
} ) . apply ( typeof pewpew , [ , , 2 ] ) ;
Back to top