ES6 Shartli operator

React ES6

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();

Ushbu sahifada

Xato haqida xabar berish