An open API service indexing awesome lists of open source software.

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

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