Skip to main content
added 24 characters in body
Source Link

Use ^ instead of != or == when comparing to an integer

Before:

//x!=3?a:b

After:

  x^3?a:b

//x==3?a:b
  x^3?b:a

Replace calls to built-in Math functions with shorter expressions

//Math.ceil(n)
  n%1?-~n:n

//Math.floor(n)
  ~~n
  0|n

//Math.abs(n)
  n<0?-n:n

//Math.round(n)
  n+.5|0

//Math.min(x,y)
  x<y?x:y

//Math.max(x,y)
  y<x?x:y

Use ^ instead of != when comparing to an integer

Before:

x!=3?a:b

After:

x^3?a:b

Replace calls to built-in Math functions with shorter expressions

//Math.ceil(n)
  n%1?-~n:n

//Math.floor(n)
  ~~n
  0|n

//Math.abs(n)
  n<0?-n:n

//Math.round(n)
  n+.5|0

//Math.min(x,y)
  x<y?x:y

//Math.max(x,y)
  y<x?x:y

Use ^ instead of != or == when comparing to an integer

//x!=3?a:b
  x^3?a:b

//x==3?a:b
  x^3?b:a

Replace calls to built-in Math functions with shorter expressions

//Math.ceil(n)
  n%1?-~n:n

//Math.floor(n)
  ~~n
  0|n

//Math.abs(n)
  n<0?-n:n

//Math.round(n)
  n+.5|0

//Math.min(x,y)
  x<y?x:y

//Math.max(x,y)
  y<x?x:y
added 307 characters in body
Source Link

Use ^ instead of != when comparing to an integer

Before:

x!=3?a:b

After:

x^3?a:b

Replace calls to built-in Math functions with shorter expressions

//Math.ceil(n)
  n%1?-~n:n

//Math.floor(n)
  ~~n
  0|n

//Math.abs(n)
  n<0?-n:n

//Math.round(n)
  n+.5|0

//Math.min(x,y)
  x<y?x:y

//Math.max(x,y)
  y<x?x:y

Use ^ instead of != when comparing to an integer

Before:

x!=3?a:b

After:

x^3?a:b

Use ^ instead of != when comparing to an integer

Before:

x!=3?a:b

After:

x^3?a:b

Replace calls to built-in Math functions with shorter expressions

//Math.ceil(n)
  n%1?-~n:n

//Math.floor(n)
  ~~n
  0|n

//Math.abs(n)
  n<0?-n:n

//Math.round(n)
  n+.5|0

//Math.min(x,y)
  x<y?x:y

//Math.max(x,y)
  y<x?x:y
Source Link

Use ^ instead of != when comparing to an integer

Before:

x!=3?a:b

After:

x^3?a:b