??C # 연산자를 JavaScript 에 적용해야하는 요구 사항이 있는데 방법을 모르겠습니다. C #에서 이것을 고려하십시오.
int i?=null;
int j=i ?? 10;//j is now 10
이제 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
어떻게 올바르게 수행합니까?
감사.
편집 : 문제의 절반을 발견했습니다 my_object[0]. 객체에 '인덱서'표기법을 사용할 수 없습니다 ( ). 그것을 우회하는 방법이 있습니까? (사전에 필터 속성의 이름을 모르고 반복하고 싶지 않습니다).