To use the without
function from the Underscore library in TypeScript, you first need to install the Underscore library via an NPM package. Here are the basic steps:
index.ts23 chars2 lines
without
function in your TypeScript module:index.ts228 chars11 lines
Note that without
returns a new array with the specified values removed. It does not modify the original array.
One thing to note is that if you want to use without
with a generic array type (e.g. Array<T>
or T[]
), you may see TypeScript compiler errors around the types of the values being passed to without
. To fix this, you can use a type assertion to tell TypeScript the specific type of the array elements:
index.ts374 chars14 lines
In this example, the Person
interface is defined as:
index.ts52 chars5 lines
gistlibby LogSnag