re: Protip: JSON ignores 'undefined' VIEW POST

FULL DISCUSSION
 

Since the value either exists or is undefined,

donkey.fur_pos.map(i => i[3] ? i[3] : undefined)

can be simplified to:

donkey.fur_pos.map(i => i[3])

It's inaccurate though to say that the undefined will be removed - in what way are you using it for which this is the case?

What you can do however is eg:

donkey.fur_pos
    .map(i => i[3])
    .filter(Boolean)

which will remove all falsey statements including undefined and null, but also 0 and false, so you may want a more robust filter function, depending on your objective.

 
code of conduct - report abuse