check if two objects are both undefined or null in javascript -
i have method hittest check collision detection , can homecoming point object (if collision happened) or (if there no collision) returns null or undefined (i haven't understand when homecoming null or undefined trust chrome console).
i have test collision on 2 objects. , check if 1 or 2 collisions happening. have tried code:
var result1 = hittest(player, object1); var result2 = hittest(player, object2); if( result1 || result2 ) { blabla() }; but doesn't work.
now.. know js reallly tricky language , think smart way without writing typeof 4 times. i'm thinking python short-circuit logical operators...
you can utilize &&, returns first detected false/null/undefined/0, i.e. if won't pass, if either result1 or result2 null.
javascript null undefined logical-operators
No comments:
Post a Comment