왜 내가 그런 일을 할 수 없습니까?Javascript RegExp as property
var obj = {
prop1:"a",
prop2:"b",
test1: new RegExp(this.prop1),
test2: new RegExp(this.prop2),
init: function(){
if(this.test1.test('apple')){
//code will be executed
}
if(this.test1.test('banana')){
//code will be executed
}
if(this.test2.test('apple')){
//code will be executed
}
if(this.test2.test('banana')){
//code will be executed
}
}
};
obj.init();
시험은 항상 /(?:)/
이기 때문에 true를 반환합니다. 이 문제를 해결하는 방법? 좋아
은 무엇 정확히 수행 할? 귀하의 질문은 무엇인가 ? – tnanoba
정확히 무엇을하고 싶습니까? 귀하의 질문은 무엇인가 ? 친구 – Neel
@ 오닐, 나는 '친구'하하를 놓쳤다 – tnanoba