<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <script> console.log(isFinite(NaN)); console.log(isFinite(Infinity)); console.log(isFinite(-Infinity)); console.log(isFinite(0)); console.log(isFinite(10)); console.log(isFinite(‘10‘)); </script> </body> </html>
结果如下:
所以,isFinite() 的作用就是,当参数不是NaN、Infinity、-Infinity 时,返回true。
时间: 2024-12-31 03:53:58