Coding Niggles

Exists?

Javascript:

  foo = foo || "bar"; // yay!
PHP:

  $foo = $foo ? $foo : "bar"; // boo!

Function defaults

PHP:

function x($foo = 'bar'){ // yay!
Javascript:

function x(foo){ // boo!
  foo = foo || "bar"; 

Ranges

PHP:

foreach (range(1,10) as $i) // yay!
Javascript:

for (i=1; i<11; i++) // boo!

Join

Javascript:

foo = bar.join(', ') // yay!
PHP:

$foo = implode(', ', $bar) // hmm
Python:

foo = ', '.join(bar) // boo!

New arrays

Javascript:

foo = [] // yay!
PHP:

$foo = array() // boo!