1
이 코드는 recursion의 섹션에서 가져온 것입니다.Javascript의 이상한 절 좋은 부분
typeof actual === 'string' && (actual === value || typeof value !== 'string')
방법이 다릅니다 :
var getElementsByAttribute = function (att, value) {
var results = [];
walk_the_DOM(document.body, function (node) {
var actual = node.nodeType === 1 && node.getAttribute(att);
if (typeof actual === 'string' &&
(actual === value || typeof value !== 'string')) {
results.push(node);
}
});
return results;
};
나는 아래 조항의 점을 이해하지? 그리고 경우에만 actual
문자열이며, 하나 actual === value
, 또는 value
이 문자열이 아닌 경우
typeof actual === 'string' && actual === value
첫 번째 조건은 '값 === 42'에 대해 true입니다. – Tibos
오오오, 이처럼 5 분 동안 쳐다 보면서 마침내 두 개의 다른 변수의 '문자열'이 '값'과 '실제' . –
@AlexWayne 나는 더 오랫동안 응시해야했다 ... –