Skip to content
View snsxn's full-sized avatar
💭
I may be slow to respond.
💭
I may be slow to respond.

Block or report snsxn

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse

Pinned Loading

  1. One-line group an Array by an Object... One-line group an Array by an Object Property - JavaScript ES2015, ES6
    1
    const groupBy = (arr, groupFn) => arr.reduce((grouped, obj) => ({...grouped,[groupFn(obj)]: [...(grouped[groupFn(obj)] || []), obj], }), {});
    2
    
                  
    3
    // Using it
    4
    const people = [
    5
      { name: 'Matt' },
  2. 3x one-liner Shuffle Array - JavaScr... 3x one-liner Shuffle Array - JavaScript ES2015, ES6
    1
    // Original gist
    2
    const shuffleArray = arr => arr.sort(() => Math.random() - 0.5);
    3
    
                  
    4
    // Fully random by @BetonMAN
    5
    const shuffleArray = arr => arr.map(a => [Math.random(), a]).sort((a, b) => a[0] - b[0]).map(a => a[1]);