DEV Community

BekmuhammadDev
BekmuhammadDev

Posted on

Frontend Question part-2

** Uchlik operator (?:)**
Uchlik operator shartlarni tekshirishda ishlatiladi va quydagicha ishlaydi.

let result = shart ? true_holat : false_holat;

Enter fullscreen mode Exit fullscreen mode
  • Shart: True yoki False qiymat qaytaradigan ibora.
  • Agar shart true bo‘lsa, true_holat qaytadi; aks holda, false_holat qaytadi.

  • Shartli operator (True yoki False qaror qabul qiladi)

  • Uch qismdan iborat (shart, true, false)

Misol:

let age = 18;
let natija = age >= 18 ? "Kirish mumkin" : "Kirish mumkin emas";
console.log(natija); //kirish mumkin chunku age 18 ga teng 18 = 18 ga true holat.

Enter fullscreen mode Exit fullscreen mode

**

  1. Nullish birlashtiruvchi operator (??)**

Bu operator null yoki undefined qiymatlarni tekshirish uchun ishlatiladi. Agar chap tomondagi qiymat null yoki undefined bo‘lsa, o‘ng tomondagi qiymat qaytariladi.

misol:

let username = null;
let defaultName = "Mehmon";
let natija= username ?? defaultName;
console.log(natija); // "Mehmon" username null qiymatga teng va u chapda joylashgan natija Mehmon.

Enter fullscreen mode Exit fullscreen mode
  • Agar chap_tomon null yoki undefined bo‘lsa, o‘ng_tomon qaytadi.
  • Aks holda, chap_tomon qaytariladi.

Image of Docusign

Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay