swami swami - 1 year ago 156
React JSX Question

javascript jsx map on result of logical or

I want to have an expression like:

{phones.map((phone, j) =>

but phones array may not always be defined.

Is there something like this possible:

(phones || []).map()

Answer Source

you can check it like below,

const self = this;
   {phones !== undefined ? phones.map((phone, j) => 
   : null}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download