⊗jstsPmBsOTC 8 of 55 menu

Checking the type of a variable in an object in TypeScript

TypeScript controls the type of the variable with the object, prohibiting writing data of a different type to it. Let's look at an example. Let's say we have an object with a user:

let user = {name: 'john', age: 30};

Let's try to write data of a different type to this variable, for example, a string. We'll get an error:

user = 'eric'; //

Without running the code, determine what the result of executing the code will be:

let date = {year: 2025, month: 12, day: 31}; date = '2025-12-31'; console.log(date);
enru