It appears it does not work in Stackblitz, but can Object.values()
be used in general in Angular projects?
IIUC Angular includes CoreJS and the purpose of it is to allow things like Object.values()
to be available across all browsers?
It appears it does not work in Stackblitz, but can Object.values()
be used in general in Angular projects?
IIUC Angular includes CoreJS and the purpose of it is to allow things like Object.values()
to be available across all browsers?
In order for typescript to recognize Object.values
, the developer should add to tsconfig.json compilerOptions: {lib: ["esnext"]}
. Stackblitz simply does not have this setting.
Angular absolutely can utilize this feature, because it is well supported by modern browsers (except old IE, as always)
Depends on which browser you're targetting. It won't work as such in non-supported browsers. You can find a list of Supporting Browsers here
That being said, you can still use it in Older Browsers by using Polyfills. You can find these polyfills here.
Polyfills are used in place of JS that is not available as a part of a Browser. If lib
from tsconfig
is used, it is going to compile/transpile the TypeScript into a suitable version of JavaScript specified in the lib
array. So adding lib: "es2017"
to tsconfig
would mean it won't work on browsers that don't implicitly support ES2017.
But adding a Polyfill instead would mean that it would also work on browsers that don't support this script.