EasyManua.ls Logo

Euresys Coaxlink - Page 27

Euresys Coaxlink
45 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Euresys GenApi scriptsCoaxlink Programmer's Guide
var x = 3;
x += 2;
x -= 1;
x *= 3;
x /= 5;
assertEqual(2.4, x);
// Logical OR: ||
assertEqual(true, false || true);
assertEqual('ok', false || 'ok');
assertEqual('ok', 'ok' || 'ignored');
// Logical AND: &&
assertEqual(false, true && false);
assertEqual(true, true && true);
assertEqual('ok', true && 'ok');
// Identity (strict equality) and non-identity (strict inequality): === !==
assertEqual(true, 1 === 2 / 2);
assertEqual(true, 1 !== 2);
// Equality (==) and inequality (!=) JavaScript operators lead to confusing
// and inconsistent conversions of their operands. They are not implemented
// in Euresys GenApi Script.
// Relational operators: < <= > >=
assert(1 < 2);
assert(1 <= 1);
assert(2 > 1);
assert(2 >= 2);
// Addition and subtraction: + -
assertEqual(1, 3 - 2);
assertEqual(5, 2 + 3);
assertEqual("abcdef", "abc" + "def"); // if one of the operands is of type
assertEqual("abc123", "abc" + 123); // string, all operands are converted
assertEqual("123456", 123 + "456"); // to string, and concatenated
// Multiplication and division: * /
assertEqual(4.5, 3 * 3 / 2);
// Prefix operators: ++ -- ! typeof
var x = 0;
assertEqual(1, ++x);
assertEqual(1, x);
assertEqual(0, --x);
assertEqual(0, x);
assertEqual(true, !false);
assertEqual('boolean', typeof false);
assertEqual('number', typeof 0);
assertEqual('string', typeof '');
assertEqual('undefined', typeof undefined);
assertEqual('function', typeof function () {});
assertEqual('object', typeof {});
assertEqual('object', typeof []);
assertEqual('object', typeof /re/);
assertEqual('object', typeof null);
// Postfix operators: ++ --
var x = 0;
assertEqual(0, x++);
assertEqual(1, x);
assertEqual(1, x--);
assertEqual(0, x);
// Function call: ()
assertEqual(6, multiply(3, 2));
// Member access: . []
var obj = { a: 1 };
assertEqual(1, obj.a);
obj['4'] = 'four';
assertEqual('four', obj[2*2]);
}
// Scope of variables
function OuterFunction() {
var x = 'outer x';
function Shadowing() {
assertEqual(undefined, x);
var x = 'inner x';
assertEqual('inner x', x);
}
function Nested() {
assertEqual('outer x', x);
27

Related product manuals