I need to check if thevar[2] === 'debug' however thevar[2] might be undefined so if I ran the following code with it being undefined javascript would throw an error:
if (thevar[2] === 'debug') {
console.log('yes');
}
So what I'm currently doing is:
if (typeof thevar[2] !== 'undefined') {
if (thevar[2] === 'debug') {
console.log('yes');
}
}
Is this really the best way to do this?