I am using ternary expression to check if the variable exists to display value accordingly, but since, I need to check both if it exists and that is has some values in it, it fails on checking the condition when the variable is undefined. How can I fix that?
This is the code:
$('#select').selectize({
items: typeof icoop != "undefined" && icoop != null || icoop.selectedUsers.length < 1 ? icoop.selectedUsers : []
});
I get:
Uncaught ReferenceError: icoop is not defined