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.
hasOwnProperty- developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…"x" in t. But it's a duplicate and a frequent question.