Hello, I have a requiremnt to apply the ?? C# operator to JavaScript world and don't know how. Consider this in C#:
int i?=null;
int j=i ?? 10;//j is now 10
Now I have this set up in JavaScript:
var options={
filters:{
firstName:'abc'
}
};
var filter=options.filters[0]||'';//should get 'abc' here, it doesn't happen
var filter2=options.filters[1]||'';//should get empty string here, because there is only one filter
How do I do it correctly?
Thanks.
EDIT: I spotted half of the problem: I can't use the 'indexer' notation to objects (my_object[0]). Is there a way to bypass it? (I don't know the names of the filters properties beforehand and don't want to itereate over them).