Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

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 modeExit 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 modeExit 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 modeExit fullscreen mode
  • Agar chap_tomon null yoki undefined bo‘lsa, o‘ng_tomon qaytadi.
  • Aks holda, chap_tomon qaytariladi.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

FrontendDevpleper
  • Location
    Uzbekistan Tahkent
  • Joined

More fromBekmuhammadDev

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp