What does the “as const” mean in TypeScript and what is its use case?
5
I am confused about the as const
cast. I checked a few documents and videos but did not understand it fully.
My concern is what does the as const
mean in the code below and what is the benefit of using it?
const args = [8, 5] as const;
const angle = Math.atan2(...args);
console.log(angle);
typescript type-assertion
1
will always beone (1)
in maths, numbers are constants because they cannot be changed. – Chloe Anderson Apr 7 at 19:56