is-defined-eval
v1.0.3
Published
Evaluates is-defined expression and returns the value of the evaluation
Downloads
18
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):
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