Skip to content

Instantly share code, notes, and snippets.

@azproduction
Created August 9, 2011 11:26
Show Gist options
  • Save azproduction/1133802 to your computer and use it in GitHub Desktop.
Save azproduction/1133802 to your computer and use it in GitHub Desktop.
What the ideologically better for JavaScript?
function onlyStringArgument(string) {
if (typeof string !== "string") {
throw new Error('string must be a string');
}
return string.split(';');
}
onlyStringArgument(42);
function onlyStringArgument(string) {
return String(string).split(';');
}
onlyStringArgument(42);
function onlyStringArgument(string) {
return string.split(';');
}
onlyStringArgument(42);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment