JavaScript: Optional chaining (?.)

 The optional chaining operator (?.) enables you to read the value of a property located deep within a chain of connected objects without having to check that each reference in the chain is valid.

The ?. operator is like the . chaining operator, except that instead of causing an error if a reference is nullish (null or undefined), the expression short-circuits with a return value of undefined. When used with function calls, it returns undefined if the given function does not exist.

The optional chaining operator provides a way to simplify accessing values through connected objects when it's possible that a reference or function may be undefined or null.
 

Example:

const customer = {
  name: "Carl",
  details: {
    age: 82,
    location: "Paradise Falls" // detailed address is unknown
  }
};

const customerCity = customer.details?.address?.city;

// … this also works with optional chaining function call

const customerName = customer.name?.getName?.();

// method does not exist, customerName is undefined

 

Readmore: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining

 

chain

@chain /tʃein/
* danh từ
- dây, xích
- dãy, chuỗi, loạt
=a chain of mountains+ một dãy núi
=a chain of events+ một loạt các sự kiện
- thước dây (để đo chiều dài); dây (chiều dài của thước dây, bằng 20m115)
- dây chuyền (làm việc...)
=to form a chain+ làm thành dây chuyền, đứng thành dây chuyền
- (số nhiều) xiềng xích
=to break the chains+ phá xiềng xích
* ngoại động từ
- xích lại, trói buộc, buộc chặt ((nghĩa đen) & (nghĩa bóng))
- ngáng dây (qua đường phố...)
- đo bằng thước dây

@chain
- (Tech) chuỗi, dây chuyền, dây xích; nối kết ký lục; chuỗi vận hành; lần lượt (tt)

@chain
- dây xích, dây chuyền chuỗi
- c. of syzygies (đại số) xích [hội xung, xiziji]
- atternating c. dây xích đan, dây chuyền đan
- finite c. (xác suất) xích hữu hạn
- Marcop (xác suất) xích Maccốp
- normal c. dây chuyền chuẩn tắc
- reducible c. (đại số) dây chuyền khả quy
- smallest c. (tô pô) dây chuyền nhỏ nhất

located

@locate /lou'keit/
* ngoại động từ
- xác định đúng vị trí, xác định đúng chỗ; phát hiện vị trí
- (từ Mỹ,nghĩa Mỹ) đặt vào một vị trí
- (từ Mỹ,nghĩa Mỹ) đặt vị trí (để thiết lập đường xe lửa, xây dựng nhà cửa...)

@locate
- định xứ, định vị trí; được đặt

simplify

@simplify /'simplifai/
* ngoại động từ
- làm đơn giản, đơn giản hoá

@simplify
- rút gọn, đơn giản