DEV Community

loading...

Discussion on: Top 20 JavaScript tips and tricks to increase your Speed and Efficiency

Collapse
bugb profile image
bugb • Edited

Unfortunately, in the real life, data are much more complex, I think if you can share about how to composite functions then it should be very helpful.

My tips

const string = 'kapilalipak';
[...string].reduce((m,n)=>({...m,[n]:-~m[n]}),{})
// {"k":2,"a":3,"p":2,"i":2,"l":2}

Enter fullscreen mode Exit fullscreen mode