I have a js object as below.
var t = { x: 0, y: 'string', v: 10000 };
my present code is.
if (!t.x || !t.y) {
throw "x and y required";
}
My problem is in my code x
can have the value 0
but if in that case I do a !t.x
then I get true.
How can I ensure that my data has x
and y
and also ensure that x
can have the value 0
.
jsfiddle: https://jsfiddle.net/3jo7vx4p/
Any help is sincerely appreciated.