You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Cast the "unknown" variable myVar as a string, using the `as` keyword:letmyVar: unknown="Hello world!";// var as type✅console.log((myVarasstring).length);
// Declare an object kindPerson from the Person interface, where all the properties are `optional`:interfacePerson{age: number;firstName: string;lastName: string;}// Partial ??? 属性可选letkindPerson : Partial<Person>={};
// Declare an object kindPerson from the Person interface, where all the properties are `required`.interfacePerson{age: number;firstName: string;lastName?: string;}// 必须滴 ✅letkindPerson : Required<Person>={age: 1800,firstName: "Santa",lastName: "Claus"};
TypeScript Exercise
https://www.w3schools.com/typescript/exercise.php?filename=exercise_casting1
https://www.w3schools.com/typescript/exercise.php?filename=exercise_casting2
https://www.w3schools.com/typescript/exercise.php?filename=exercise_utility_types1
https://www.w3schools.com/typescript/exercise.php?filename=exercise_utility_types2
https://www.w3schools.com/typescript/exercise.php?filename=exercise_utility_types3
refs
https://www.cnblogs.com/xgqfrms/p/17053678.html
The text was updated successfully, but these errors were encountered: