javascript isset equivalent

i was just looking for an equivalent to the isset in php for javascript, i was initially using .length but this can still cause errors so i found this solution.
if (typeof my_var !== 'undefined') {}

Javascript

var my_var = "something";
if (typeof my_var !== 'undefined') {
var note = 'do something if my variable exists and has something in it';
console.log(note);
}
if (typeof not_my_var !== 'undefined') {
var note = 'this should not run or cause errors unless not_my_var has a value even though it it not declaired anywhere';
console.log(note);
}

Other Items in javascript
Page Views

This page has been viewed 24 times.

Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

❤👩‍💻🕹

Random Quote
Even if you fall on your face, you're still moving forward.
Victor Kiam