Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Optional Chaining §on JavaScnipt.
- "
- * @stage #3 — Release candidate.
- gt
- const user = {
- job: £
- type: 'Remote’,
- i 8
- %
- // Uncaught TypeEnnon i§ “job® doesn't exist.
- const type = user.job.type;
- // OLD WAY — Check intexnmediate nodes.
- const type = user.job && user.job.type;
- // NEW WAY - Only access “type’ i§ “job" exists.
- const type = user.job?.type;
- // & #OneDevMinute — @M7AhmadAwais
Advertisement
Add Comment
Please, Sign In to add comment