
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
is-var-name
Advanced tools
Check if a string can be used as a JavaScript variable name
isVarName('foo'); //=> true
isVarName('f o o'); //=> false
npm install is-var-name
import isVarName from 'is-var-name';
name: string
Return: boolean
It returns true
if the string can be used as a valid JavaScript identifier name. If not, or the argument is not a string, it returns false
.
isVarName('______________'); //=> true
isVarName('å'); //=> true
isVarName('123'); //=> false
isVarName('↑→↓←'); //=> false
isVarName('_;'); //=> false
isVarName(''); //=> false
isVarName(['foo']); //=> false
isVarName(); //=> false
Instead of this module, you can use the regular expression that matches valid variable names.
is-var-name uses Function
constructor but regular expression doesn't.
According to the ESLint documentation, new Function()
is:
considered by many to be a bad practice due to the difficult in debugging and reading these types of functions.
Since the regular expression is too long (about 16,000 characters), it increases the file size of your library or application.
ISC License © 2018 Shinnosuke Watanabe
FAQs
Check if a string can be used as a JavaScript variable name
We found that is-var-name demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.