A Laravel(ish) Optional helper in Javascript

Will Bowman
asked.io
Published in
1 min readApr 9, 2018

My attempt at creating an optional helper.

Laravels optional helper can be pretty useful. With its new optional closure you can do even more.

I wanted something similar in javascript so I wrote this based on my Laravel(ish) resource/transformer.

You can also provide a callback that will be called if the option exists.

--

--