if (obj.hasOwnProperty('foo')) { // your code here }
var status = 'Variable exists' try { myVar } catch (ReferenceError) { status = 'Variable does not exist' } console.log(status)