Skip to content

Instantly share code, notes, and snippets.

View saxenanickk's full-sized avatar
🏠
Working from home

Nikhil Saxena saxenanickk

🏠
Working from home
View GitHub Profile
@ashwin1014
ashwin1014 / utils.js
Last active March 22, 2024 05:20
Some handy javascript utility functions to use in a project
export const isEmpty = (obj) => [Object, Array].includes((obj || {}).constructor) && !Object.entries(obj || {}).length;
export const uid = () => Date.now().toString(36) + Math.random().toString(36).substr(2, 5);
export const uniqueObjArray = (arr, prop) => {
return Array.from(new Set(arr.map((a) => a[prop]))).map((item) => {
return arr.find((a) => a[prop] === item);
});
};