ES6 Shartli operator

React ES6

SU

React ES6 Ternar Operator

Ternar Operator

Ternar operator if / else kabi shartli operatorning soddalashtirilgan shaklidir.

Sintaksis: shart ? <haqiqiy bo'lsa ifoda> : <yolg'on bo'lsa ifoda>

Misol: if / else yordamida

if (authenticated) {
  renderApp();
} else {
  renderLogin();
}

Ternar operator bilan

authenticated ? renderApp() : renderLogin();

Last updated on

On this page

Xato haqida xabar berish