Skip to content

Latest commit

 

History

History
44 lines (34 loc) · 872 Bytes

.verb.md

File metadata and controls

44 lines (34 loc) · 872 Bytes

Primitive values

The Mozilla docs for "Primitive values" defines specifies six data types that are primitives:

  • Boolean
  • Null
  • Undefined
  • Number
  • String
  • Symbol (new in ECMAScript 6)

Usage

var isPrimitive = require('{%= name %}');

true

All of the following return true:

console.log(isPrimitive(false));
console.log(isPrimitive(true));
console.log(isPrimitive(null));
console.log(isPrimitive());
console.log(isPrimitive(42));
console.log(isPrimitive('abc'));
console.log(isPrimitive(Symbol()));
//=> true

false

Everything else returns false:

console.log(isPrimitive({}));
console.log(isPrimitive([]));
console.log(isPrimitive(function(){}));
console.log(isPrimitive(new Date()));
// et cetera...
//=> false