Skip to content

Intro to the operator methods ​

Note

In the function editor, you can perform any JS methodusing values from cookies, variables, parameters, request responses, inputs, or forms. Be sure to use the parameters correctly.

Addition (+) ​

Description Adds two numbers or concatenates strings. Be cautious: mixing numbers and strings triggers type coercion.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
return (sum = 3 + 5); // 8
return (text = 'Price: $' + 99); // "Price: $99"

Subtraction (-) ​

Description Subtracts two numbers. Converts strings to numbers if possible (e.g., "5" - 2 → 3).

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
return (result = 10 - 3); // 7

Multiplication (*) ​

Description Multiplies two numbers. Non-numeric values are coerced to numbers (e.g., "2" * "3" → 6).

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
return (total = 4 * 5); // 20

Division (/) ​

Description Divides two numbers. Returns Infinity if divided by 0.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
return (quotient = 15 / 3); // 5

Modulus (%) ​

Description Returns the remainder of a division. Useful for even/odd checks or cyclic patterns.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
return (remainder = 10 % 3); // 1 (10 ÷ 3 = 3 with remainder 1)

Exponentiation (**) ​

Description Raises a base to the power of an exponent (e.g., 2 ** 3 → 8).

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
return (power = 2 ** 4); // 16

Increment (++) ​

Description Increases a number by 1. Use as prefix (++x) or postfix (x++).

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
let count = 5;
return count++; // count becomes 6

Decrement (--) ​

Description Decreases a number by 1. Use as prefix (--x) or postfix (x--).

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
let count = 5;
return count--; // count becomes 4

Equality (==) ​

Description Compares values with type coercion (e.g., 5 == "5" → true). Avoid in most cases.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
return 5 == '5'; // true

Strict Equality (===) ​

Description Compares values and types (no coercion). Preferred for reliable comparisons.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
return 5 === '5'; // false

Inequality (!=) ​

Description Checks if values are different with type coercion.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
return 5 != '5'; // false (due to coercion)

Strict Inequality (!==) ​

Description Checks if values or types differ (no coercion). Safer than !=.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
return 5 !== '5'; // true

Greater Than (>) & Less Than (<) ​

Description Compares numeric values or string lexicographical order.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
return 10 > 5; // true
return 'apple' < 'banana'; // true (a < b alphabetically)

Greater Than or Equal (>=) & Less Than or Equal (<=) ​

Description Similar to >/< but includes equality.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
return 5 >= 5; // true

Logical AND (&&) ​

Description Returns true if both operands are truthy. Returns the first falsy value or last truthy.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
return true && 5 > 3; // true

Logical OR (||) ​

Description Returns true if at least one operand is truthy. Returns the first truthy value.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
return false || 'default'; // "default"

Logical NOT (!) ​

Description Inverts a boolean value. Converts truthy/falsy values to boolean.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
return !true; // false

Assignment (=) ​

Description Assigns a value to a variable.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
let x = 10;
return x;

Add & Assign (+=) ​

Description Adds a value to a variable and updates it.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
let total = 5;
return (otal += 3); // total = 8

Ternary Conditional (? :) ​

Description Shorthand for if-else. Syntax: condition ? exprIfTrue : exprIfFalse.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
const access = age >= 18 ? 'Granted' : 'Denied';
return access;

Nullish Coalescing (??) ​

Description Returns the right-hand operand if the left is null or undefined.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
return i.login_name ?? 'Guest';

Optional Chaining (?.) ​

Description Safely accesses nested properties. Returns undefined if any chain link is null/undefined.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
return r.request_name.data.user?.address?.city;

typeof ​

Description Returns a string indicating the type of a variable.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
return typeof 'hello'; // "string"

Spread (...) ​

Description Expands arrays/objects into individual elements. Used for copying, merging, or function arguments.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
const merged = [...arr1, ...arr2];
return merged;

Nullish Assignment (??=) ​

Description Assigns a value only if the variable is null/undefined.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
let config = null;
return (config ??= { theme: 'light' }); // config becomes { theme: "light" }

Logical AND Assignment (&&=) ​

Description Assigns a value only if the variable is truthy.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
let value = 'Hello';
return (value &&= 'Updated'); // value becomes "Updated"

in ​

Description Checks if a property exists in an object.

javascript
/* Keep in mind that this example has fixed values, however,
you can replace any value with a value from a cookie, variable, form, input, etc. */
return 'name' in { name: 'Alice' }; // true