Advanced TypeScript: A Generic Function to Update and Manipulate Object Arrays

Advanced TypeScript: A Generic Function to Update and Manipulate Object Arrays

Advanced TypeScript: A Generic Function to Update and Manipulate Object Arrays. I realized a common pattern kept cropping up in my array manipulation functions. The body of our new generics the identity function would then take on the same type of form as these two expanded functions. Another fancy generic function of ultimate power!

Another fancy generic function of ultimate power!

This post is mirrored on my blog, where you’ll find way better code snippets — they’re copy-and-pasteable too!

Always Pushing for Cleaner Code

While building my newest SaaS product,  ReduxPlate, I realized a common pattern kept cropping up in my array manipulation functions. I was always updating a specific value at a specific key, based on a specific test on some other key.

*Plug: Speaking of ReduxPlate, which automatically generates Redux code for you, __I’m writing a book that documents every step I took along the way to build ReduxPlatefrom boilerplate starters to the finished live product. I’d love it if you check it out! Yes, You’ve read this correctly! I literally build ReduxPlate from start to finish, right before your eyes — and the code is all public!

For example, for the editor widget on the  ReduxPlate homepage, I use a stateful array of type IEditorSettings to determine which editor is currently active and what the actual code value is in the editor:

export default interface IEditorSetting {

    fileLabel: string
    code: string
    isActive: boolean
}

coding programming typescript javascript

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Principles of Functional Programming in JavaScript That Will Make Your Coding Life Easier

Who else loves to write side-effects-free functions? I think we, as programmers, all do. Today, in this story, I will walk you through the basic principles of functional programming that will make your coding life easier.

4 Ways You Can Get Rid of Dirty Side Effects for Cleaner Code in JavaScript

4 Ways You Can Get Rid of Dirty Side Effects for Cleaner Code in JavaScript. Bugs are born in many ways. Creating side effects is one of them. Some people say side effects are evil, some say they’re not.

Object-Oriented Programming with Javascript — using Typescript

Object-Oriented Programming With JavaScript — Using Typescript. TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. TypeScript is pure Object-oriented with classes, interfaces, and statically typed like C# or Java.

Who Else Wants to Write Clean JavaScript Code?

Who Else Wants to Write Clean JavaScript Code? 7 Tips to Make Your Coworkers Fall in Love With Your Code.

Code Formatting with Prettier in Visual Studio Code

Formatting code consistently is a pain, especially when working on a team. The beauty of modern-day web development is that the tooling has gotten so much better! In this article, we will look at setting up Prettier to automatically format your code in Visual Studio Code.