is-defined-eval

1.0.3 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i is-defined-eval

Weekly Downloads

1

Version

1.0.3

License

MIT

Last publish

Collaborators

  • diversen