Your solution will fail if we do doThing(null). Null is also an object in JS, as you klnow. Once in the method, execution will fall into the if statement and we'll end up having an error kinda "Cannot read property 'x' of null"
You are absolutely correct. I forgot to also check for null! The if should read: if (typeof x === 'object' && x != null) I have pinned your comment so others can be alerted to this potential bug. Cheers 🍻
@@JoelCodes I think that by doing this your function can fail again because if I don't name the object keys like 'x' and 'y' your function will set doThing(undefined, undefined)