Skip to content

Instantly share code, notes, and snippets.

@pasikonik
Last active November 28, 2023 12:17
Show Gist options
  • Save pasikonik/777246c46a348782bb690b860f80d973 to your computer and use it in GitHub Desktop.
Save pasikonik/777246c46a348782bb690b860f80d973 to your computer and use it in GitHub Desktop.
JavaScript snippets
// 1. Get a random integer between two integers
const random = (min, max) => Math.floor(Math.random() * (max - min + 1) + min)
// 2. Check if an object is an empty object
const isEmpty = obj => Reflect.ownKeys(obj).length === 0 && obj.constructor === Object
// Shuffle array
const shuffleArray = (arr) => arr.sort(() => Math.random() - 0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment