Total newbie here but can someone explain this line of code?
Items: Text ? this.getFilteredItems(this._allItems) : this._allItems
Thanks
S
Total newbie here but can someone explain this line of code?
Items: Text ? this.getFilteredItems(this._allItems) : this._allItems
Thanks
S
For further actions, you may consider blocking this person and/or reporting abuse
Bhanu Sunka -
Rubén Alapont -
SREY -
Akashdeep Patra -
Top comments (3)
That is a ternary operator (developer.mozilla.org/en-US/docs/W...)
the line says that, if there is a
Text
run the functiongetFilteredItems
and if the text is undefined or null, return all the items(this._allItems).Ternary operator is a simplified and shorter way to do a conditional statement.
Thanks Alfred
When you say " if there is a Text"
Where is it looking for text?
This code means :
if(Text){
return this.getFilteredItems(this._allItems)
} else {
return this._allItems
}
It's a simple ternary expression.