How to Remove an Object's Property in JavaScript Without Mutation

Hiiiiiii there, today I will be sharing a useful JavaScript Tip which you can use to avoid Mutation when dealing with objects. To mutate something is to change it; it is to alter its form. Deleting an Object’s property is Mutation Say you have a user object defined like this: const user = { firstName: 'John', lastName: 'Obajeti', gender: 'Male', password: 'safest' } Assuming you need to send this object as part of an API Response, you will want to remove the password field. You can do this by using the delete keyword: ...

March 11, 2022

JS Tip: How to Shuffle An Array in JavaScript

Hi there, today I will be sharing a tip on shuffling an array in JavaScript. The algorithm we will come up with can actually be implemented in any programming language but I will be doing it in JavaScript. Input Say we are given an array of a primitive type in JavaScript e.g [1, 3, 4, 5, 6, 2] or ["Tom", "Jerry", "Parker", "Wick"] Output The output is an array that contains the same elements as the first array but the order of those elements have been randomized ...

March 8, 2022