Files
it-know-how/typescript/bits/03-dot-access-and-method-calls.md
T
2026-03-27 12:58:01 +01:00

552 B
Executable File

Dot Access and Method Calls

Dot notation accesses properties and methods on objects.

Property Access

const user = { name: 'Mathias', age: 30 };
console.log(user.name); // 'Mathias'

Method Call

const text = 'hello';
console.log(text.toUpperCase()); // 'HELLO'

In your code:

backendPeriodLabelFormatter.formatToParts(date)
  • backendPeriodLabelFormatter is an object.
  • formatToParts is a method.
  • (date) passes the argument.

Python Comparison

Equivalent idea to obj.attr and obj.method(arg).