It happens to me that I make the same mistake in logical conditions. When I want something to happened for the conditions something is not or other something is not I write this which is wrong:
if(el.type !== 'hidden' || !el.disabled) {
el.value = '';
}
It should be this way
if(false === (el.type === 'hidden' || el.disabled)) {
el.value = '';
}
I think: I want to clear elements value when its type is not hidden or its not disabled... - writing it down in English programming language makes bad condition.
How should I think about this logical problem to write it down right?
Aucun commentaire:
Enregistrer un commentaire