728x90

✨ 문자의 정렬 순서를 비교를 통해 알아낼 수 있는 helper method

💻Example Code

 

 

실행 결과

🧨
의 비교 문자가의 비교 문자보다 정렬 순서가 앞이라면 -1
의 비교 문자가 의 비교 문자보다 정렬 순서가 같다면 0
의 비교 문자가 의 비교 문자보다 정렬 순서가 뒤라면 1
이 출력되는 것을 확인할 수 있다.

👉 자세한 내용은 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare

 

String.prototype.localeCompare()

The localeCompare() method returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order.

developer.mozilla.org

 

'JavaScript > Built-in Method etc.' 카테고리의 다른 글

String.prototype.charAt()  (0) 2020.02.22
Set (Object)  (0) 2020.02.20
Math.round()  (0) 2020.02.16
Math.abs()  (0) 2020.01.28
Math.PI  (0) 2020.01.28

+ Recent posts