Created
March 4, 2012 20:07
-
-
Save hhamon/1974593 to your computer and use it in GitHub Desktop.
Optional arguments in JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Reversi.prototype.getNewCell = function (row, col) { | |
var cell = { 'row': 0, 'col': 0 }; | |
if (undefined !== row) { | |
cell.row = parseInt(row); | |
} | |
if (undefined !== col) { | |
cell.col = parseInt(col); | |
} | |
return cell; | |
}; |
ubermuda
commented
Mar 4, 2012
Reversi::getNewCell = (row, col) -> row: ~~row, col: ~~col
how do you get the coloring? :/
also, what is ~~
?
NEVERMIND (bitwise not applied two times)
but the fact that ~undefined == -1
is... disturbing.
@n1k0 nice but unreadable :)
@arnaudlimbourg you get used to it :)
@ubermuda comme ça:
```coffeescript
foo = 42
```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment