Skip to content

Instantly share code, notes, and snippets.

@gwa
Created February 7, 2014 15:06
Show Gist options
  • Save gwa/8864420 to your computer and use it in GitHub Desktop.
Save gwa/8864420 to your computer and use it in GitHub Desktop.
JavaScript variable assign in a conditional
var m = '12';
// conditional needs a clause, not just an assignment, so compare to null to see if a match Array is returned.
if ((m = value.match(/^([\d]+)$/)) != null) {
return parseInt(m[1], 10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment