JavaScript의 숫자 구분 기호

개발자 여러분, 안녕하세요.

이 기사에서는 ECMAScript21(12판)에 소개된 가장 놀라운 기능 중 하나인 Numeric Separator에 대해 논의해 보겠습니다.

내용의 테이블


  • Introduction
  • Some Examples
  • Conclusion

  • 1. 소개

    This feature enables developers to make the numeric literals more readable.
    What I mean to say is, large numeric literals (both integers and floating-point) which are difficult for the human eye to parse quickly, especially when there are long digit repetitions, this feature of ES12 makes it simple to read.

    How?

    Please read this number

    let num = 1000000000000
    

    if someone is reading the value of num verbally, then in the first sight one cannot be able to read it. So numeric separator help developers make it readable in the first sight.

    Let's see how it helps.

    Now, read this number

    let num = 100_000_000_000 
    

    첫 번째 것보다 읽기가 조금 더 쉬웠습니까? 예인 경우 알려주세요.




    2. 예시

    Let see some examples,

    1. equality & strict equality
    let num1 = 1000000000000 
    let num2 = 100_000_000_000
    
    console.log(num1==num2) //true
    console.log(num1===num2) //true
    
    1. What is the output in console for number with underscore in it?
    let num = 100_000_000_000
    console.log(num) //100000000
    
    1. We can use underscore with Binary, Octal, Hex numbers are well
    let num1 = 0b1010_0101_1001 // binary
    let num2 = 0o2_3_5_7 // octal
    let num3 = 0xA_B_C_D_E // hex
    

    3. 결론

    Awesome! Now you have learnt 1 new feature of JavaScript, I hope you have now a very clear idea regarding underscore between digits in numeric literals.

    Thank you for reading this far. This is a brief introduction of Numeric Separator In JavaScript.

    If you find this article useful, share this article. Someone could find it useful too. If you find anything technically inaccurate, please feel free to create a issue .

    그것이 당신을 위한 멋지고 유익한 읽기가 되기를 바랍니다.
    자세한 내용을 보려면 https://www.capscode.in/blog을 방문하십시오...
    다음 블로그 기사에서 뵙겠습니다. 건강하세요!!

    감사,
    캡스코드

    좋은 웹페이지 즐겨찾기