Reply To: Default parameters in functions

#14323085
Kal Starkis
Member

I believe ExtendScript is based on ye olde ES3, while default parameters are a feature of ES6, so you’re out of luck I’m afraid.

As for your workaround, that should work in JavaScript, but ExtendScript can be a strange and unpredictable beast at times. In your sample code there, I notice you have ‘smart’ quotes around ‘undefined’, but I’m guessing that’s not in your actual code? You could try testing your variables directly against undefined instead:

function doSomething (a, b, c) {
b = (b !== undefined) ? b : null;
c = (c !== undefined) ? c : 100;
// do scripty things
}

This article was last modified on February 12, 2020

Comments (0)

Loading comments...