How can I compare a non-existing JavaScript object to undefined without getting a Reference Error?

Use this:

(typeof task === "undefined")

When you use (task === undefined), Javascript needs to find the value of task to see if it is the same as undefined, but it can’t look up the name because it doesn’t exist, giving you the reference error. typeof is special in that it can safely return the type of a name that doesn’t exist.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)