If you don't care about the return value of the IIFE, it could also be any of the following:
!function(){}(); // => true
~function(){}(); // => -1
+function(){}(); // => NaN
-function(){}(); // => NaNLet's explore this a bit more.
| class Reduced { | |
| static isReduced(inst) { | |
| return (inst instanceof Reduced); | |
| } | |
| constructor(wrapped) { | |
| this._wrapped = wrapped; | |
| } | |
| unwrap() { |
| -- bar a b c = c + b - 2 * a | |
| -- foo ... = bar ... | |
| -- foo ... = ... bar ... | |
| fib :: Integer -> Integer | |
| fib n = fn n (0, 1) | |
| where | |
| fn 0 (a, b) = a | |
| fn n (a, b) = fn (n - 1) (a + b, a) |
| $gridPadding: 7px; | |
| @define-mixin padding-double $p { | |
| &._padding-h { | |
| &:nth-child(odd) { padding: 0 $p 0 0 } | |
| &:nth-child(even) { padding: 0 0 0 $p } | |
| } | |
| &._padding-v { | |
| padding: $p 0 $p 0; |
| "use strict"; | |
| function recur (f) { | |
| return f(f); | |
| } | |
| function wrap (h) { | |
| return recur(function (f) { | |
| return h(function (n) { | |
| return f(f)(n); |
| function queue (operations, finished = []) { | |
| let [curr, ...rest] = operations; | |
| return !curr ? Promise.resolve(finished) : new Promise(resolve => { | |
| curr() | |
| .then(result => { | |
| resolve(queue(rest, finished.concat(result))); | |
| }) | |
| .catch(() => { | |
| resolve(queue(rest, finished)); |
| function fibonacci (n) { | |
| const fn = (n, a, b) => n === 0 ? a : fn(n - 1, a + b, a); | |
| return fn(n, 0, 1); | |
| }; | |
| function factorial (n) { | |
| const fn = (n, acc) => n === 0 ? acc : fn(n - 1, n * acc); | |
| return fn(n, 1); | |
| } |
| // with array. More more more faster | |
| Array.apply(null, Array(100)).map((_, i) => { | |
| var n = i + 1; | |
| return (n % 3 === 0 && n % 5 === 0 ? 'FizzBuzz' : | |
| (n % 3 === 0 ? 'Fizz' : | |
| (n % 5 === 0 ? 'Buzz' : n))) | |
| }); | |
| // with recursion | |
| const fizzBuzz = (size, acc = []) => { |
| start = | |
| element | |
| validchar = [0-9a-zA-Z\-_\{\}\.\:\/] | |
| _ = [ \t\r\n]* | |
| tagAttrs = | |
| _ name:validchar+ '="' value:validchar+ '"' _ { |
| function multi(pred) { | |
| const methods = new Map(); | |
| const fn = (...args) => { | |
| const f = methods.get(pred(...args)); | |
| return f ? f(...args) : null; | |
| }; | |
| fn.method = (predKey, methodFn) => { | |
| methods.set(predKey, methodFn); |
If you don't care about the return value of the IIFE, it could also be any of the following:
!function(){}(); // => true
~function(){}(); // => -1
+function(){}(); // => NaN
-function(){}(); // => NaNLet's explore this a bit more.