Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function(anInt, aString, cb, aBool=true){
- if(bool){...;}else{...;}
- cb();
- }
- function(1, 'no', function(){
- ...
- }, false);
- function(2, 'yes', function(){
- ...
- });
- var variable1 = typeof variable1 !== 'undefined' ? variable1 : default_value;
- function(anInt, aString, cb, aBool) {
- aBool = typeof aBool !== 'undefined' ? aBool : true;
- if(bool){...;}else{...;}
- cb();
- }
- var sayMessage = function(message='This is a default message.') {
- console.log(message);
- }
- node --harmony_default_parameters --eval "const t = function(i = 42) { return i }; console.log(t());"
- fn1 = fn.bind(fn, 1, 'no', function(){}, false);
- fn1();
- fn2 = fn.bind(fn, 2, 'yes', function(){});
- fn2(true);
- CoffeeScript:
- fn = (bar='foo') ->
- JavaScript:
- fn = function(bar) {
- if (bar == null) {
- bar = 'foo';
- }
- };
Add Comment
Please, Sign In to add comment