Reputation: 1235
I'm trying to set a global if it doesnt exist. Total noob question.
I'm doing this:
if (!raw) {
raw = 'yep';
}
But it keeps throwing reference error raw is not defined.
Upvotes: 0
Views: 56
Reputation: 1424
This is one way, assuming window
exists:
if(!window.raw) {
raw = 'yup';
}
If not, you could just make a global object to use:
globals = {};
if(!globals.raw) {
globals.raw = 'yup';
}
Upvotes: 2