Skip to content

SWML - Document that SWML uses v8 7.8 for JS expressions. #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Devon-White opened this issue Apr 22, 2025 — with Slack · 0 comments
Open

SWML - Document that SWML uses v8 7.8 for JS expressions. #221

Devon-White opened this issue Apr 22, 2025 — with Slack · 0 comments

Comments

Copy link
Contributor

Devon-White commented Apr 22, 2025

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.

let x; // assume this is defined at some point

let b = 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:

let x = 0;
let b = 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:

let b = (x !== undefined && x !== null) ? x : 5;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant