+ 1

What it does mean by ! in this function?

function myFunction() { var inpObj = document.getElementById("id1"); if (!inpObj.checkValidity()) { document.getElementById("demo").innerHTML = inpObj.validationMessage; } }

14th Jul 2018, 11:45 AM
Nayem
1 Odpowiedź
+ 1
! is the not-operator Meaning, that true becomes false and vice versa. So in this example the validation message will be shown, if the object is not valid. At least I assume so, I don't know much about JavaScript. But ! is definitley the not-operator. !true = false !false = true
14th Jul 2018, 11:49 AM
Matthias
Matthias - avatar