183| });
184|
>> 185| <% if(just_registered) { %>
186| alert("Welcome!");
187| <% } %>
188|
just_registered is not defined
Basically, I want to say: if just_registered is defined and is true, then alert. However, I want want to set everything to false…I just want to leave it undefined (i have like 100 variables)
<% if(typeof just_registered !== "undefined") { %>Basically your checking whether a local variable exists. To do this you have to use the
typeofoperator since accessingjust_registeredwhich is an undeclared local variable creates a reference error.This is best compared to
vs
Where as
Will work because accessing an undeclared variable with the typeof operator just returns
"undefined"rather then throwing aReferenceError