主页
TypeScript
TypeScript 对象类型
demo_object_types_optional
运行 ❯
×
更改方向
保存代码
更改主题
// no error on optional property, remove it and see what happens const car: { type: string, mileage?: number } = { type: "Toyota" }; car.mileage = 2000; console.log(car);
{ type: 'Toyota', mileage: 2000 }