You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
v8 version 7.8 is what SMWL uses to utilize JS expressions in SWML.
Additional Notes
Fallback values
Given V8 version 7.8 (from 2019), the nullish coalescing operator (??) was not yet supported in that version. So, you would typically use the logical OR (||) operator for fallback values.
letx;// assume this is defined at some pointletb=x||5;
How it works:
If x is any "falsy" value (undefined, null, 0, '', false, NaN), b will be set to 5.
If x is any "truthy" value, b will be set to x.
Example:
letx=0;letb=x||5;// b will be 5, because 0 is falsy
Caveat
If you want b to be 0 when x is 0, or ' ' when x is an empty string, then || is not suitable. But in V8 7.8, you don't have ??, so you have to use || or write a more verbose check:
letb=(x!==undefined&&x!==null) ? x : 5;
The text was updated successfully, but these errors were encountered:
v8 version 7.8 is what SMWL uses to utilize JS expressions in SWML.
Additional Notes
Fallback values
Given V8 version 7.8 (from 2019), the nullish coalescing operator (??) was not yet supported in that version. So, you would typically use the logical OR (||) operator for fallback values.
How it works:
x
is any "falsy" value (undefined
,nul
l,0
, '',false
,NaN
),b
will be set to5
.x
is any "truthy" value,b
will be set tox
.Example:
Caveat
If you want
b
to be0
whenx
is0
, or' '
whenx
is an empty string, then||
is not suitable. But in V8 7.8, you don't have??
, so you have to use||
or write a more verbose check:The text was updated successfully, but these errors were encountered: