Menu

gitpiper

isPrimitive javascript Code Snippet in 2024

typeintermediate

Last Updated: 16 December 2024

Checks if the passed value is primitive or not.

  • Create an object from val and compare it with val to determine if the passed value is primitive (i.e. not equal to the created object).
const isPrimitive = val => Object(val) !== val;
isPrimitive(null); // true isPrimitive(undefined); // true isPrimitive(50); // true isPrimitive('Hello!'); // true isPrimitive(false); // true isPrimitive(Symbol()); // true isPrimitive([]); // false isPrimitive({}); // false

javascript snippet similar to isPrimitive For You in December 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️