Demo entry 3548457

Pseudomentatory parameters in ES6 functions

   

Submitted by anonymous on Jan 13, 2016 at 16:35
Language: JavaScript. Code size: 267 Bytes.

const _err = function( message ){
   throw new Error( message );
 }

 const getSum = (a = _err('a is not defined'), b = _err('b is not defined')) => a + b

getSum( 10 ) // throws Error, b is not defined
getSum( undefined, 10 ) // throws Error, a is not defined

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).