My application has an HTML form with some inputs populated from the backend and other inputs being entered by the user (in a time
input). An onChange
function runs through each input when the user changes a value.
The inputs populated from the backend are converted to moment
objects, the user-entered dates are mere strings. This means the onChange
function encounters some moment
objects, and some strings. I need to know which inputs are moment
objects and which aren't.
What's the recommended method for testing if a variable is a moment
object?
I've noticed moment
objects have a _isAMomentObject
property but I'm wondering if there's another way to test if a variable is a moment
object.
Another option I've tried is calling moment
on the variable regardless. This converts the string
variables to moment
objects and doesn't seem to effect existing moment
objects.