I always thought I could just check an undefined var by comparing it to undefined, but this is the error I get in the chrome console :

How how do i check for the object jQuery being undefined ?
EDIT :

if(jQuery) is giving me problems too
EDIT :
solution :
if(window.jQuery) works.
typeof(jQuery) == 'undefined' works too.
Could anyone explain why ?
There are several solutions:
Use
typeof. It is a special operator and will never result in aReferenceError. It evaluates to “undefined” for, well, theundefinedvalue or for a variable which does not exist in context. I’m not a fan of it, but it seems very common.Use
window.jQuery. This forces a “property lookup”: property lookups never fail, and returnundefinedif said property does not exist. I’ve seen it used in some frameworks. Has the downside of assuming a context (usuallywindow).Make sure the variable is “declared”:
var jQuery; if (jQuery) { /* yay */ }. Doesn’t seem very common, but it is entirely valid. Note thatvaris just an annotation and is hoisted. In the global context this will create the “jQuery” property.Catch the
ReferenceError. Honestly, I have never seen this nor do I recommend it, but it would work.Happy coding.