I came accross value = String(event.target.value || "") when a textinputs keyup/keydown event is fired.
But i'm not sure when the event.target.value is not a string? Is this possible? When is something else passed off as an event.target.value?
If the event.target element is not an input type element, it will not have a value property. For example, if I click a div then event.target is a div which does not have value.
Wrapping event.target.value || '' in String() is not necessary as it will always be either value (which is always a string or undefined) or the empty string in the case that value is undefined.
See this fiddle for a demonstration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With