is-identifier
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

is-identifier

Check if a string is a valid JavaScript identifier

Install

npm install is-identifier

Usage

import isIdentifier from 'is-identifier';

isIdentifier('foo');
//=> true

isIdentifier('1kg');
//=> false

isIdentifier('await'); // Reserved identifier
//=> false

[!NOTE] Although globalThis, Infinity, NaN, and undefined are properties of the global object and not identifiers, they are treated as reserved here because they should generally not be used as identifiers.

API

isIdentifier(value)

Returns a boolean for whether the given value is a valid JavaScript identifier.

Related

Package Sidebar

Install

npm i is-identifier

Weekly Downloads

52,381

Version

1.0.0

License

MIT

Unpacked Size

3.99 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus