observable.observe(fnObserver)
let result = null;
// pipelining functions (current solution)
result = doFn4(doFn3(doFn2(doFn1(string)));
// with pipline operator
result = string |> doFn1 |> doFn2 |> doFn3 |> doFn4;
Pipeline Operator for expressions, array functions, (async) function-calls
// or
a ||= b;
a || (a = b);
// and
a &&= b;
a && (a = b);
Inspired by Ruby. Works exactly as in Ruby
const arr = ['a', 'b', 'c', 'd'];
console.log(arr[1:3] == arr.slice(1,3)); // ['b', 'c']
console.log(arr[:2] == arr.slice(0,2)); // ['a', 'b']
console.log(arr[2:] == arr.slice(2,4)); // ['c', 'd']
console.log(arr[2:] == arr.slice(2)); // ['c', 'd']
console.log(arr[-1:] == arr.slice(3,4)); // ['d']
console.log(arr[:-2] == arr.slice(0,3)); // ['a', 'b']
Slice Notation for arrays and objects
Inspired by Python. Works exactly as in Python
const inhabitantsOfMunich = 1_464_301;
const distanceEarthSunInKm = 149_600_000;
const massOfElectronInKg = 9.109_383_56e-31;
const words = 0xFAB_F00D;
let result = Number.parseInt('123_345');
console.log(result == 123456);
let result = Number.parseFloat('0.123_456');
console.log(result == 0.123456);
identical specification & restrictions as in Java 8
const massOfEarthInKg = 6_000_000_000_000_000_000_000_000n;
let bigInt = typeof 123n;
console.log(bigInt == 'bitInt');
let result = BigInt.parseInt('9007199254740993', 10);
console.log(result == 9007199254740993n);
console.log(0 == 0n); // false :(
identical usage as with any 'number'
BitInts will have a huge impact for money-related applications (financial technical sector)
let arr = [1, 2, 3, 4, 5, 6, 7];
console.log(arr.last == arr[arr.length - 1]);
console.log(arr.first == arr[0]);
Convenient access to special elements
// for loop
for (let item in items) {
arr.add(item);
}
arr.addAll(items);
arr.addAll(...items);
arr.addAll(item1, item2, ..., itemN);
Convenient add/remove of multiple elements
class SomeClass {
#xValue = 0; // private field
get #x() { return #xValue; } // private getter
set #x(value) { this.#xValue = value; } // private setter
#someMethod(args) { ... }; // private method
}
prefix any class element using '#' to make it private
private methods & fields might have a huge impact