K
K
Kotaro Hiba2019-12-03 20:40:15
Pug
Kotaro Hiba, 2019-12-03 20:40:15

What do these operators mean?

I started to study pug, please tell me what these operators mean:
classes += options.type ? ' button_' + options.type : ''
options.text || 'Button'
in Pug.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Glebov, 2019-12-03
@lina666

the same as js
ternary operator
https://developer.mozilla.org/ru/docs/Web/JavaScri...
+=
https://learn.javascript.ru/operators#sokraschyonn...
options.text || 'Button' is a check for a non-empty variable, will return options.text if there is something there or 'Button'
https://learn.javascript.ru/logical-operators#ili-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question