Repository navigation
Expand file tree
/
Copy pathapp.js
More file actions
13 lines (13 loc) · 2.76 KB
/
Copy pathapp.js
File metadata and controls
13 lines (13 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
//Working with "optional chaining"
function getCustomer(id) {
return id === 0 ? null : { birthday: new Date() };
}
var customer = getCustomer(1);
//Optional property access operator
console.log(customer === null || customer === void 0 ? void 0 : customer.birthday.getFullYear());
//optional element access operator
//customer?.[0]
//optional call
var log = null;
log === null || log === void 0 ? void 0 : log('a');
console.log(log);