• Breaking News

    Best way to code JavaScript if you are living in 2019

    This is a collection of snippets that may help you to improve your JavaScript code style.

    ES6 introduced a lot of handy features, some of them are really useful to clean your code and help your teammates by delivering more readable code.

    I've found myself not touching a for/while loop again!





    These are my suggested snippets, give it a try and then let me know.

    Best way to group an array of objects by key




    Methods used: reduce() and concat().

    Best way to sort an array by first name (alphabetically)




    Methods used: sort() and localeCompare().

    Best way to sort  an array of JSON objects numerically




    Methods used: sort().

    Best way to find counterpart object members 




    Methods used: delete() and values().

    Best way to code logical operations




    Methods used: some().

    Best way to concatenate  array operations




    Methods used: filter() and map().

    Best way to get unique values from a multidimensional array




    Methods used: filter() and map().

    Best way to get unique values from a multidimensional




    Methods: flat() and filter().


    Let me know your thoughts in the comments section.

    No comments