May 7, 2017

[HDGEM] JavaScript self-executing anonymous function


// Traditional syntax:
var value = function( x ) { return x !== -1 ? x : 0 }( someArray.indexOf(3) );

// ES6 syntax:
var value = ( x => x !== -1 ? x : 0 )( someArray.indexOf(3) );



--
Posted By Blogger to HDGEM at 5/07/2017 02:05:00 AM