1

What does the (0, fs.existsSync)(...) expression do and what is the definition of this expression?

Example

let exists = (0, fs.existsSync)('/usr/bin/chromium-browser');

if (exists) {
  return;
}

// ... other code here

throw new Error('...')

I code in JavaScript for 10+ years and just came across this expression in a library, but I have no idea what this is.

I believe to understand the expression converts the undefined value returned by fs.existsSync to 0 if the file /usr/bin/chromium-browser doesn't exist and otherwise returns true. However, I can't find any expression or operator definition on mozilla.org or anywhere else.

All operators and expressions on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators don't match any of the signatures of the expression.

Jay
  • 1,564
  • 16
  • 24

0 Answers0