강의

멘토링

커뮤니티

Inflearn Community Q&A

holynow1475's profile image
holynow1475

asked

From a beginner to launching a web service: 2021 Jeju Coding Base Camp (Django)

Data type_String_includes

indexOf 에 대한 설명중에 궁금한게 있습니다.

Written on

·

204

0

강의 마지막에

let txt = 'ABCDEFGHIJKABC'

txt.indexOf('AB', 2)

위의 코드대로 2가 두번째 매개변수로 들어왔을때
두번째로 'AB' 가 몇번째에 있는지 결과값이 11 나왔습니다.

그리고 txt.indexOf('AB', 3) 

라고 했을경우 3번째에 AB가 없어서 결과가 안나오는거라고 하셨고요

그런데 변수 txt 에 값을 ABCDEFGHIJKABCDGABC 라고 변경해서

txt.indexOf('AB', 3)  이 코드를 다시 호출해보았는데도 

txt.indexOf('AB', 2) 의 결과값과 동일하게 나왔습니다.

재미있는건 txt.indexOf('AB', 1) 이렇게 해도 결과값이

똑같이 11이 나옵니다.

설명이 잘못된걸까요??

linuxbootstrapdjangopythonjquerygitHTML/CSSjavascript

Answer

This question is waiting for answers
Be the first to answer!
holynow1475's profile image
holynow1475

asked

Ask a question