문자열과 문자열의 배열을 모두 가지고 있습니다.javascript indexOf가 문자열 및 배열과 어떻게 다르게 작동합니까?
var strFruit = "Apple is good for health";
var arrayFruit = ["Apple is good for health"];
var strResult = strFruit.indexOf("Apple"); //strResult shows 0
var arrayResult = arrayFruit.indexOf("Apple"); // arrayResult shows -1
하지만 arrayFruit.indexOf("Apple is good for health")
arrayResult를 사용하는 경우 0
쇼와 같이 IndexOf이 아닌 문자열과 방법을 모두 검색 다른 배열 요소의 일치를 찾습니다 그런데 왜 내 질문 이다?
PS :이 질문을하는 주된 이유는 내가 .I 이해할 수 indexOf
의 소스 코드를 이해 할 수없는 오전 은 문자열과 확실하지 array.But 메신저로 (indexOf
) 무엇을어떻게 문자열 및 배열? (poly fills or source code)와 함께 작동합니다.