Introduction to new features of numerical expansion
Numerical expansion mainly adds some new features, such as new methods and method adjustments
1. Binary numerical representation (use 0B as the prefix, b is indifferent Uppercase and lowercase) Octal numerical representation (use 0o as prefix)
{ console.log('B',0B111110111); console.log(0o767); }
2. Number.isFinite (finite) Number. isNaN (not a number)
{ console.log('15',Number.isFinite(15));//true console.log('NaN',Number.isFinite(NaN));//false console.log('1/0',Number.isFinite('true'/0));//false console.log('NaN',Number.isNaN(NaN));//true console.log('0',Number.isNaN(0));//false}
3. Number.isInteger (determine whether it is an integer, note: the received parameter must be a number)
{ console.log('25',Number.isInteger(25));//true console.log('25.0',Number.isInteger(25.0));//true console.log('25.1',Number.isInteger(25.1));//false console.log('25.1',Number.isInteger('25'));//false }
4. Number.MAX_SAFE_INTEGER (2 to the 53rd power) Number.MIN_SAFE_INTEGER (2 to the -53rd power) (these two are the upper and lower integers)
You can use Number.isSafeInteger to determine whether it is within the above range
{ console.log(Number.MAX_SAFE_INTEGER,Number.MIN_SAFE_INTEGER); console.log('10',Number.isSafeInteger(10));//true console.log('a',Number.isSafeInteger('a'));//false }
5. Math.trunc (get The integer part of the decimal is not rounded)
{ console.log(4.1,Math.trunc(4.1));//4 console.log(4.9,Math.trunc(4.9));//4 }
6. Math.sign (Judge positive and negative numbers, return -1 for negative number, return 0 for 0, return 1 is a positive number)
{ console.log('-5',Math.sign(-5));//-1 console.log('0',Math.sign(0));//0 console.log('5',Math.sign(5));//1 console.log('50',Math.sign('50'));//1(传递的参数为字符串数字 仍然当做数字) console.log('foo',Math.sign('foo'));//NaN(传递的参数是字符串 返回NaN) }
7. Math.cbrt (returns the cube root of a number)
{ console.log('-1',Math.cbrt(-1));//-1 console.log('8',Math.cbrt(8));//2 }
There are also some new APIs such as trigonometric functions and logarithms, which are not listed here
The above is the detailed content of Introduction to new features of numerical expansion. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

To extend PHP function functionality, you can use extensions and third-party modules. Extensions provide additional functions and classes that can be installed and enabled through the pecl package manager. Third-party modules provide specific functionality and can be installed through the Composer package manager. Practical examples include using extensions to parse complex JSON data and using modules to validate data.

The Xiaomi Mi 15 series is expected to be officially released in October, and its full series codenames have been exposed in the foreign media MiCode code base. Among them, the flagship Xiaomi Mi 15 Ultra is codenamed "Xuanyuan" (meaning "Xuanyuan"). This name comes from the Yellow Emperor in Chinese mythology, which symbolizes nobility. Xiaomi 15 is codenamed "Dada", while Xiaomi 15Pro is named "Haotian" (meaning "Haotian"). The internal code name of Xiaomi Mi 15S Pro is "dijun", which alludes to Emperor Jun, the creator god of "The Classic of Mountains and Seas". Xiaomi 15Ultra series covers

When editing text content in Word, you sometimes need to enter formula symbols. Some guys don’t know how to input the root number in Word, so Xiaomian asked me to share with my friends a tutorial on how to input the root number in Word. Hope it helps my friends. First, open the Word software on your computer, then open the file you want to edit, and move the cursor to the location where you need to insert the root sign, refer to the picture example below. 2. Select [Insert], and then select [Formula] in the symbol. As shown in the red circle in the picture below: 3. Then select [Insert New Formula] below. As shown in the red circle in the picture below: 4. Select [Radical Formula], and then select the appropriate root sign. As shown in the red circle in the picture below:

The Charm of Learning C Language: Unlocking the Potential of Programmers With the continuous development of technology, computer programming has become a field that has attracted much attention. Among many programming languages, C language has always been loved by programmers. Its simplicity, efficiency and wide application make learning C language the first step for many people to enter the field of programming. This article will discuss the charm of learning C language and how to unlock the potential of programmers by learning C language. First of all, the charm of learning C language lies in its simplicity. Compared with other programming languages, C language

Learn Pygame from scratch: complete installation and configuration tutorial, specific code examples required Introduction: Pygame is an open source game development library developed using the Python programming language. It provides a wealth of functions and tools, allowing developers to easily create a variety of type of game. This article will help you learn Pygame from scratch, and provide a complete installation and configuration tutorial, as well as specific code examples to get you started quickly. Part One: Installing Python and Pygame First, make sure you have

Since the Huawei Mate60 series went on sale last year, I personally have been using the Mate60Pro as my main phone. In nearly a year, Huawei Mate60Pro has undergone multiple OTA upgrades, and the overall experience has been significantly improved, giving people a feeling of being constantly new. For example, recently, the Huawei Mate60 series has once again received a major upgrade in imaging capabilities. The first is the new AI elimination function, which can intelligently eliminate passers-by and debris and automatically fill in the blank areas; secondly, the color accuracy and telephoto clarity of the main camera have been significantly upgraded. Considering that it is the back-to-school season, Huawei Mate60 series has also launched an autumn promotion: you can enjoy a discount of up to 800 yuan when purchasing the phone, and the starting price is as low as 4,999 yuan. Commonly used and often new products with great value

Title: Learn the main function in Go language from scratch. As a simple and efficient programming language, Go language is favored by developers. In the Go language, the main function is an entry function, and every Go program must contain the main function as the entry point of the program. This article will introduce how to learn the main function in Go language from scratch and provide specific code examples. 1. First, we need to install the Go language development environment. You can go to the official website (https://golang.org

Laravel is a popular PHP development framework with rich functions and flexible scalability. The Redis extension is a commonly used database caching tool. This article will deeply explore the use of Redis extensions in Laravel, introduce its basic concepts, configuration methods and specific code examples in detail to help developers better use Redis extensions to improve system performance. 1. What is RedisRedis is an open source memory data storage system, also known as
