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

1.0.1 • 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

94,046

Version

1.0.1

License

MIT

Unpacked Size

3.97 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus