Purpose:
- Primarily for developer tooling, such as for "rename" refactoring.
Syntax:
nameof IdentifierName
Examples:
// operand must be an IdentifierName
const obj = {};
nameof obj; // "obj"
// The IdentifierName does not need to be an initialized declaration
nameof C; // "C"
class C {}
// In fact, the IdentifierName doesn't even need to be a valid declaration
nameof DoesNotExist; // "DoesNotExist"
// Any valid IdentifierName is permitted
nameof package; // "package" (future reserved word)
nameof this; // "this"
nameof function; // "function"
nameof delete; // "delete"