MENU
Boolean Operators
The operators that return a Boolean value are: > : greater than >= : greater than or equals < : less than <= : less than or equals == : equals in evaluated value === : equals in value and type in : is a property of instanceof: is an object of
RESETRUNFULL
<!DOCTYPE html><html><body><script>
console.log(3<3); // falseconsole.log(3<=3); // trueconsole.log(3==3); // trueconsole.log(3===3); // true
console.log(3==new Number(3)); // trueconsole.log(3===new Number(3)); // falseconsole.log(typeof 3); // numberconsole.log(typeof new Number(3)); // objectconsole.log(new Number(3)==new Number(3)); // falseconsole.log(new Number(3)===new Number(3)); // false
</script></body><html>
RESETRUNFULL
<!DOCTYPE html><html><body><script>
function F(){this.x=100;}class C extends F{}var o = new C;console.log(o instanceof C); // trueconsole.log(o instanceof F); // trueconsole.log('x' in o); // true
</script></body><html>
To assign default values, the or operator(||) or the nullish coaslescing operator(??) can be used.
RESETRUNFULL
<!DOCTYPE html><html><body><script>
const
nullValue = null,
numberValue = 300,
zeroValue = 0,
emptyValue = '',
falseValue = false;console.log(nullValue || 'DEFAULT'); // DEFAULTconsole.log(numberValue || 'DEFAULT'); // DEFAULTconsole.log(zeroValue || 'DEFAULT'); // DEFAULTconsole.log(emptyValue || 'DEFAULT'); // DEFAULTconsole.log(falseValue || 'DEFAULT'); // DEFAULTconsole.log("........................");console.log(nullValue ?? 'DEFAULT'); // DEFAULTconsole.log(numberValue ?? 'DEFAULT'); // DEFAULTconsole.log(zeroValue ?? 'DEFAULT'); // 0console.log(emptyValue ?? 'DEFAULT'); // ''console.log(falseValue ?? 'DEFAULT'); // false
</script></body><html>