https://github.com/diversen/is-defined-eval
Evaluates if a variable is defined
https://github.com/diversen/is-defined-eval
Last synced: 22 days ago
JSON representation
Evaluates if a variable is defined
- Host: GitHub
- URL: https://github.com/diversen/is-defined-eval
- Owner: diversen
- Created: 2017-01-15T12:48:11.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-19T22:46:11.000Z (over 9 years ago)
- Last Synced: 2025-10-27T05:04:10.645Z (9 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# is-defined-eval
Checks if a variable is defined.
(Eval)uates a variable `identifier` like this:
'typeof ' + identifier + ' !== "undefined"'
Consider it as a shortcut to the above.
Example (on nodejs in console):
~~~js
const isDefined = require('is-defined-eval');
var exportsExists = isDefined('exports');
console.log(exportsExists); // => true
var windowExists = isDefined('window');
console.log(windowExists); // => false
var documentExists = isDefined('document');
console.log(documentExists); // => false
~~~
License MIT