Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

There is an `Object.values()` on typescript?

I need to iterate all values from an Object that I'll use to filter another array.

Searching on Google I found Object.values(), but it doesn't work on typescript.

There is something equivalent that I can use on typescript?

like image 902
rneves Avatar asked Feb 10 '17 19:02

rneves


People also ask

Is everything an object in TypeScript?

Object: It describes the functionality, object helps in representing the non-primitive types that is everything except number, string, boolean, big int, symbol, undefined and null. In TypeScript Object(O uppercased) is different from object(o lowercased).

How do you know if an object has a property value?

The hasOwnProperty() method returns true if the specified property is a direct property of the object — even if the value is null or undefined . The method returns false if the property is inherited, or has not been declared at all.


1 Answers

Typescript ES5 and ES6 does not have this method, because of this we need this workaround to use the JS method:

(<any>Object).values(yourObject)
like image 98
rneves Avatar answered Oct 01 '22 16:10

rneves