ecmascript 6 - Khanacademy Javascript Canvas default parameter error -


i'm working on cool program on khanacademy.org javascript/processingjs canvas, , want use default parameters. however, showed error box:

'default parameters' available in es6 (use esnext option). 

what , how fix it?

using default parameters in way give warning mentioned:

var foo = function(param1, param2 = "some default value"){   console.log(param1 + " " + param2); } 

assigning default parameters in way described above ecmascript 6 feature , supported mozilla firefox. check browser compatibility here: https://developer.mozilla.org/en/docs/web/javascript/reference/functions/default_parameters#browser_compatibility

generally default parameters assigned in javascript in following way. suggest follow same, work fine in browsers:

var foo = function(param1, param2){    param2 = typeof param2 !== 'undefined' ?  param2 : "some default value";    console.log(param1 + " " + param2); } 

check link more details: https://developer.mozilla.org/en/docs/web/javascript/reference/functions/default_parameters


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -