The Mozilla docs for "Primitive values" defines specifies six data types that are primitives:
Boolean
Null
Undefined
Number
String
Symbol
(new in ECMAScript 6)
var isPrimitive = require('{%= name %}');
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
Everything else returns false
:
console.log(isPrimitive({}));
console.log(isPrimitive([]));
console.log(isPrimitive(function(){}));
console.log(isPrimitive(new Date()));
// et cetera...
//=> false