You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
두 번째 매개변수로 slice() 는 end(반환받을 마지막 요소의 index + 1. end 위치의 이전 요소까지 잘라냄), splice() 는 deleteCount(배열에서 제거할 요소의 수)를 받는다.
splice() 는 세 번째 매개변수부터 삭제한 위치부터 추가할 요소를 받는다.
String.match() 와 String.matchAll()
match() 는 배열, matchAll() 은 RegExpStringIterator 반환
match() 는 g 플래그 없을 경우 일치하는 첫 부분만 반환, matchAll() 은 g 플래그 무조건 필요
match()matchAll() 모두 두 번째 매개변수는 콜백함수를 받는다.
functionreplacer(match,p1,p2,…,pN,offset,string,groups){returnreplacement;}/*match: 일치하는 문자열p1, p2, …, pN: 정규표현식에서 캡처 그룹 () 으로 찾은 각 문자열offset: 검사한 전체 문자열에서 match 문자열의 인덱스string: 검사한 전체 문자열groups: 이름이 있는 캡처 그룹 (?<name>...) 객체: groups.name*/
Math.floor() 와 parseInt()
값이 음수일 경우 반환값이 달라진다.
Math.floor() 는 소수점에서 내림한다.
parseInt() 는 단순히 소수점 이하 숫자를 없애므로 결과적으로 올림한다.
Math.floor(-14.5);// -15parseInt(-14.5);// -14
double tilde 연산자 ~~
값이 양수일 경우 Math.floor(), 음수일 경우 Math.ceil() 과 같은 결과를 얻는다.
cf. tilde 연산자 ~: NOT 비트연산