Created
February 7, 2014 15:06
-
-
Save gwa/8864420 to your computer and use it in GitHub Desktop.
JavaScript variable assign in a conditional
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
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