1

For a Google Apps Script project, I want to write something like:

if (a <> 0 ) {
    b = 1
}

But the <> inequality operator apparently doesn't exist and I can't find mention of a replacement for it. There must be one. Can someone tell me what it is?

tehhowch
  • 9,645
  • 4
  • 24
  • 42
Alexander Grillo
  • 51
  • 1
  • 1
  • 5
  • 1
    `!=` Is the "not equal to" operator. If that isn't your goal you're going to need to edit your question to be a little more in depth. – tehhowch Feb 25 '18 at 06:13
  • That answers my question. Sorry to ask such a trivial one but I could not find any examples of which operator to use. – Alexander Grillo Feb 26 '18 at 11:38

1 Answers1

2

From the Overview page:

Google Apps Script is a scripting language based on JavaScript that lets you do new and cool things with G Suite products like Docs, Sheets, Slides, and Forms. There's nothing to install — we give you a code editor right in your browser, and your scripts run on Google's servers.

They don't explicitly state which version of Javascript there, but with some digging you can turn up some additional information. Namely, any feature in JS 1.6 is available. Some features from 1.7 and 1.8 are available too, but you will typically need to discover this on your own, by debugging in the web editor.

For general purpose Javascript reference something like MDN will be your best friend.

Specifically:

Inequality (!=) The inequality operator returns true if the operands are not equal. If the two operands are not of the same type, JavaScript attempts to convert the operands to an appropriate type for the comparison. If both operands are objects, then JavaScript compares internal references which are not equal when operands refer to different objects in memory.

if (a != 0) {
    b = 1;
}
tehhowch
  • 9,645
  • 4
  • 24
  • 42