Created
February 22, 2016 17:09
-
-
Save SCdF/8a70e3a62f5af4f039a1 to your computer and use it in GitHub Desktop.
extending sigs 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
// NB: all three of these will have the same comment documentation | |
var minimumSig = function(start, mid, end) = { | |
var newMid; | |
if (arguments === 3) { | |
newMid = mid; | |
} else if (arguments === 4) { | |
newMid = arguments[2]; | |
end = arguments[3]; | |
} else { | |
// should I do something here? | |
} | |
doTheThing(start, mid, newMid, end); | |
} | |
var maximalSig = function(start, mid, newMid, end) = { | |
if (arguments === 3) { | |
newMid = mid; | |
end = arguments[2]; // because it's currently bound to newMid with end being undefined | |
} else { | |
// should I do something here? | |
} | |
doTheThing(start, mid, newMid, end); | |
} | |
var noSig = function() { | |
var start, mid, newMid, end; | |
start = arguments[0]; | |
mid = arguments[1]; | |
if (arguments === 3) { | |
newMid = mid; | |
end = arguments[2]; | |
} else if (arguments === 4) { | |
newMid = arguments[2]; | |
end = arguments[3]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment