Object Properties

Optional

// 
interface PaintOptions {
  x?: number;              // โญ๏ธ optional
  y?: number;
}

/*
interface Shape {
  paint(opts: PaintOptions = {});
}
*/

const shape = getShape();

shape.paint({ });
shape.paint({ x: 100 });
shape.paint({ y: 100 });
shape.paint({ x: 100, y: 100 });

readonly

readonly ่ˆ‡ const ็š„ไฝœ็”จๅทฎไธๅคš๏ผŒๆœƒไฟ่ญท Primitives ไธๅ—ๆ›ดๆ”น๏ผŒไฝ†ๅฐๆ–ผ Object ไพ†่ชช๏ผŒ้›–็„ถไธ่ƒฝๆ›ดๆ”น็‰ฉไปถๆœฌ่บซ๏ผŒไฝ†ๅฏๆ›ดๆ”นๅ…ถๅฑฌๆ€งใ€‚

Index Signatures

TypeScript ็š„ index signature ้กžไผผๆ–ผ Swift ็š„ subscriptใ€‚

Last updated

Was this helpful?