What is the use case for the "as const" in TypeScript?

I just started to learn Typescript and now I am confused about const assertions, I checked a few documents and videos but I didn't understand it fully. My concern is the meaning of as const on the below code, also what's the benefit of using it? Thanks.

const args = [8, 5] as const;
const angle = Math.atan2(...args);
console.log(angle);


Read more here: https://stackoverflow.com/questions/66993264/what-is-the-use-case-for-the-as-const-in-typescript

Content Attribution

This content was originally published by Cihat Şaman at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: