1

Here is the Python code that I am trying to solve this problem in JavaScript:

try:
    float(s) if '.' in s else int(s)
    return True
except ValueError:
    return False

I'm looking for the keyword equivalent to "except" in Python.

3
  • 1
    Did you bother looking at the documentation of Javascript's try statement? It would have told you exactly what you needed to know. Commented Nov 1, 2016 at 10:32
  • I've improved the grammar and made the title clearer. Commented Nov 1, 2016 at 14:59
  • Possible duplicate of Javascript Try/Catch Commented Nov 5, 2016 at 13:09

1 Answer 1

1

In javascript, we have try, catch and finally.

try {
   //may throw
} catch(ex) {
   //handle the error, where ex or what ever you choose to call it is your exception reference
} finally {
   //perform this code regardless
}
Sign up to request clarification or add additional context in comments.

Comments