1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-08-30 12:40:03 +02:00

fix: output length of string (#5227)

This commit is contained in:
Reyes Rondón
2024-03-04 09:46:22 -04:00
committed by GitHub
parent 9d4aae10b5
commit 44d3724880

View File

@@ -9,7 +9,7 @@ Here's a simple example:
let someValue: any = "Hello, TypeScript!";
let strLength: number = (someValue as string).length;
console.log(strLength); // Outputs: 20
console.log(strLength); // Outputs: 18
```
In this example, someValue is initially of type any, and we use the as operator to assert that it is of type string before accessing its length property. It's important to note that type assertions do not change the underlying runtime representation; they are a compile-time construct used for static type checking in TypeScript.