This repository was archived by the owner on Oct 23, 2018. It is now read-only.
forked from mishoo/UglifyJS
-
Notifications
You must be signed in to change notification settings - Fork 2
Operators
dangreen edited this page Jan 2, 2015
·
5 revisions
-
is set
operator:
bool a = true, b;
console.log(a?); // true
console.log(b?); // false
-
clone
of variable, if object have method__clone__
, object will be copied with it:
Array a = [], b = clone a;
b[0] = 584; // a is []
-
pow
operator:
int pow = 5 ** 2; // 25
- CoffeeScript's
modulo
operator:
Array nums = [0..9];
console.log(nums[4 %% nums.length]); // 4
console.log(nums[14 %% nums.length]); // 4
-
Existential assignment
from CoffeeScript:
defaults(Object input, Object defaults) {
for int key in defaults {
input[key] ?= defaults[key];
}
return input;
}
console.log(defaults({
compress: true
}, {
compress: false,
mangle: false
})); // { compress: true, mangle: false }
-
Existential or
also from CoffeeScript:
int a, b = 3;
console.log(a ? b); // 3
a = 11;
console.log(a ? b); // 11
- Binary operator
is
:
bool isRegExp = /[^\d]+/g is RegExp; // true
- Binary operator
isnt
:
bool isntString = 3.14 isnt String; // true
- As in CoffeeScript, you can use
chained comprassions
:
if 1 < x < 100 {
console.log("x E ( 1 ; 100 )");
}