Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Nashorn implements number of syntactic and API extensions as well. This page describes syntax and API extensions of nashorn implementation.

Conditional catch clauses

This Mozilla JavaScript 1.4 extension is also supported by Nashorn. A single try.. statement can have more than one catch clause each with it's own catch-condition.

Code Block
titleConditional catch clause example
try { 
    func()
} catch (e if e instanceof TypeError) {
     // handle TypeError here
} catch (e) {
    // handle any other..
}

Function expression closures

...

For each expressions

This is another a Mozilla JavaScript 1.6 extension supported by Nashorn. ECMAScript for..in iterates over property names or array indices of an object. for..each..in loop iterates over property values of an object rather than property names/indices. See also https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for_each...in

...