JavaScript numerical separatorThe human eye takes a long time to parse large numerical literals, particularly if many repeated digits exist. A new JavaScript programming feature allows underscores to be used as separators in numerical literals, which makes them easier to understand. A JavaScript feature called numeric separators enables us to utilize underscore as a separator for the numeric literals. For example, the number 10000 can be written as 10_000. Both Node.js and modern browsers' most recent iterations support the capability. SyntaxThe following syntax shows the numerical separator in JavaScript. ExamplesThe examples show to operate numeric separators for binary, hexadecimal, and another type of values. Example1: The following example shows a basic numeric separator in javascript for simple values. We can use decimal and simple numeric values and separators. The separator can place any position of the number, and it does not affect the original number. Output The image shows actual values and numerical separator output. Example 2: The following example shows a numeric separator in javascript for numerical values. We can use big integers and binary values with the separator. The separator can place any index number of the input number. Output The image shows actual values and numerical separator output. Example 3: The following example shows a numeric separator in javascript for various numerical values. We can use octal and hexadecimal values with the separator. The separator can place any index number of the input number. Output The image shows actual values and numerical separator output. Example 4: The following example shows a numeric separator in JavaScript for numerical values. We can use big integers and binary values with the separator. The separator can place any index number of the input number. Here, we can use addition, subtraction, and multiplication of the values. Output The image shows actual values and numerical separator output. ConclusionJavaScript numeric separator is a visual operator to understand code and long values. It helps to understand complicated mathematical operations and displays large-size data. Next TopicJavaScript prepend() method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India