To use the _.has()
function from the Underscore library in TypeScript, you need to first import the library and its types:
index.ts129 chars5 lines
Then, you can use the _.has()
function to check if an object has a certain key:
index.ts62 chars4 lines
Alternatively, you can use the in
operator in TypeScript to achieve the same result:
index.ts57 chars4 lines
Both of these snippets will output "Object has key "a"" if the object contains the key "a".
gistlibby LogSnag