Checks if the given value is defined.

Type signature

(x?: any) => boolean

Examples

defined(undefined);
// ⇒ false
Try in REPL
defined(null);
// ⇒ true
Try in REPL
defined(0);
// ⇒ true
Try in REPL
defined({ a: 1 });
// ⇒ true
Try in REPL

Questions

  • How to check if a given value is defined?
  • How to check if a given value is not undefined?

TypeScript sourceJavaScript source