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 146 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
For a long time it had seemed to me that life was about to begin - real life. But there was always some obstacle in the way, something to be gotten through first, some unfinished business, time still to be served, or a debt to be paid. Then life would begin. At last it dawned on me that these obstacles were my life.
Alfred D. Souza