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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…