As demonstrated in the following example:
document.getElementById('test1').value = null;
document.getElementById('test2').value = undefined;
<input id="test1" value="DEFAULT TEXT" />
<input id="test2" value="DEFAULT TEXT" />
An input's value is reset whenever it is set to null
, but why doesn't it also reset when it is set to undefined
?
How come it sets the value to the string "undefined"
instead?