This syntax seems to be a more compact ternary operator, is that right?
// spider syntax:
var name = somethingElse;
name = name ?? 'default name';
If so, may I suggest a slightly different form? Per a suggestion here, I re-write the above which checks a variable and defaults it if the variable is empty/false:
// suggested formats, all of which are the same
var name = somethingElse;
name = name ? name : 'default name'; // traditional ternary
name = name ?: 'default name'; // shortened ternary <-- this looks better to me
name = name || 'default name'; // just like the one above
name = name ?? 'default name'; // spider syntax
name ?= 'default name'; // really short ternary <-- I also like this
This syntax seems to be a more compact ternary operator, is that right?
If so, may I suggest a slightly different form? Per a suggestion here, I re-write the above which checks a variable and defaults it if the variable is empty/false: