is-identifier
Check if a string is a valid JavaScript identifier
Last updated 3 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install is-identifier 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.1.0                                ...           latest (5 months ago)

3 Versions

  • 1.1.0                                ...           5 months ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Total 17
Today 0
This Week 0
This Month 12
Last Day 0
Last Week 9
Last Month 3
Dependencies (2)
Dev Dependencies (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE