typescript-coding-standard Posted on 2025-03-29 Edited on 2025-04-07 In typescript Symbols count in article: 74 Reading time ≈ 1 mins. SyntaxUser optional chaining operator ? instead of &&12345678910const user = { name: 'John', address: { city: 'New York', state: 'NY' }};const city = user && user.address && user.address.city; // old wayconst city = user?.address?.city; // new way 这种方式确实简单很多,但是处理Unit Test可能会麻烦一些。 Use nullish coalescing operator ?? instead of ||12const name = user.name || 'Guest'; // old wayconst name = user.name ?? 'Guest'; // new way