An identifier is a name for variables, functions, labels in scripts.
An identifier in Nashorn is a sequence of Unicode characters with the following rules:
The following are examples of valid identifiers:
Id _id e$Id num1
The following are invalid identifiers:
4num //Cannot start with a digit emp id //Cannot contain spaces emp+id //Cannot contains the + sign break //break is a reserved word and cannot be used as an identifier
The List of Reserved Words in Nashorn Used as Keywords
break do instanceof typeof case else new var catch finally return void continue for switch while debugger function this with default if throw delete in try
The List of Future Reserved Words in Nashorn
class enum extends super const export import
The List of Future Reserved Words in Strict-Mode in Nashorn
implements let private public yield interface package protected static
Nashorn supports two types of comments:
The syntax for writing comments in Nashorn is the same as that of Java.
The following are examples of comments:
// A single-line comment var Id; /* A multi-line comment */ var et; var d;