๐Ÿ’พisPrimitive()

check if value is a primitive

JS โŸฉ values โŸฉ custom functions โŸฉ isPrimitive()

check if value is a primitive.

โ”Œโ”€โ”€ (primitive ?)
โ”‚  typeof       type         expr         value       
---------------------------------------------------------------------
โœ… object       Null         null         null
---------------------------------------------------------------------
โœ… undefined    Undefined    undefined    undefined
---------------------------------------------------------------------
โœ… number       Number       37           37
โœ… number       Number       3.14         3.14
โœ… number       Number       Math.LN2     0.6931471805599453
โœ… number       Number       Infinity     Infinity โญ๏ธ
โœ… number       Number       NaN          NaN โญ๏ธ
โœ… number       Number       Number('1')  1
โœ… number       Number       Number('ab') NaN
---------------------------------------------------------------------
โœ… bigint       BigInt       42           42n
---------------------------------------------------------------------
โœ… string       String       'bla'        'bla'
โœ… string       String       `x = ${1+2}` 'x = 3'
โœ… string       String       typeof 1     'number'
โœ… string       String       String({})   '[object Object]'
โœ… string       String       typeof xxx   'undefined'
---------------------------------------------------------------------
โœ… boolean      Boolean      true         true
โœ… boolean      Boolean      Boolean(1)   true
โœ… boolean      Boolean      !!(1)        true
---------------------------------------------------------------------
โœ… symbol       Symbol       Symbol()     Symbol()
โœ… symbol       Symbol       Symbol.iterator Symbol(Symbol.iterator)
---------------------------------------------------------------------
โŒ object       Object       {a:1}        { a: 1 }
โŒ object       User         user         User { name: 'JohnDoe' }
โŒ object       Array        [1, 2]       [ 1, 2 ]
โŒ object       Date         new Date()   2022-09-13T01:47:46.344Z
โŒ object       RegExp       /regex/      /regex/
---------------------------------------------------------------------
โŒ function     Function     function(){} [Function (anonymous)]
โŒ function     Function     Math.sin     [Function: sin]
โŒ function     Function     () => {}     [Function (anonymous)]
โŒ function     class        class {}     [class (anonymous)]
โŒ function     class        User         [class User]
โŒ function     GeneratorFunction function*(){} [GeneratorFunction (anonymous)]
---------------------------------------------------------------------

Last updated