首页 > 其他分享 >What's isNaN

What's isNaN

时间:2023-11-30 19:06:19浏览次数:23  
标签:What false 3.14 isNaN Number checkit 123 null

使用isNaN函数来判断一个变量是不是数字形式,通过下面代码可能会有更明确的认识:

function checkit(x) {
    let v = x;
    if (isNaN(x)) {
        v = 'Not a Number!';
    }else{
        v = Number(x);
    }
    console.log(x,'is',v);
 }

    checkit('123');
    checkit('-123');
    checkit('3.14');
    checkit('0.0314E+2');
    checkit(0xF);
    checkit('123F');
    checkit('abc');
    checkit(null);
    checkit(false);
    checkit(true);
    checkit(undefined);

输入结果:

123 is 123
-123 is -123
3.14 is 3.14
0.0314E+2 is 3.14
15 'is' 15
123F is Not a Number!
abc is Not a Number!
null 'is' 0
false 'is' 0
true 'is' 1
undefined 'is' 'Not a Number!'

需要注意的是:

123F is Not a Number!
null 'is' 0
false 'is' 0
true 'is' 1

标签:What,false,3.14,isNaN,Number,checkit,123,null
From: https://blog.51cto.com/livestreaming/8633283

相关文章

  • What's new in dubbo-go-pixiu v1.0.0
    dubbo原生网关dubbo-go-pixiuv1.0https://github.com/apache/dubbo-go-pixiu/releases/tag/v1.0.0-rc2正式发版了,项目从2019年一路走来,四年磨剑,感谢从铁城、张天到吕梦超三位负责人。目前,dubbo-go-pixiu可作为dubbo/dubbogo服务网关,也可作为dubbo/dubbogo服务的s......
  • Makefile - What is a Makefile and how does it work?
    Ifyouwanttorunorupdateataskwhencertainfilesareupdated,the make utilitycancomeinhandy.The make utilityrequiresafile, Makefile (or makefile),whichdefinessetoftaskstobeexecuted.Youmayhaveused make tocompileaprogramf......
  • 【pwn】[FSCTF 2023]What am I thinking? --pwntools工具的利用
    这道题没给附件,直接就是nc这个题目的意思是,我们随机输入一个数,然后发给我们一段base64加密后的密文,真正num就在里面,我们现在写个pwntools脚本提取一下这段base64密文,解密一下,看看是什么东西exp:io=remote("node4.anna.nssctf.cn",28045)io.sendline(str(2))io.recvuntil(b"......
  • 如何用SaleSmartly集成WhatsApp账号(内含WhatsApp个人号、商业号、API号对比图)
    用SaleSmartly集成WhatsApp账号如果企业有多个WhatsApp账号,无论是个人账号还是工作账号,员工操作起来可能会觉得难以管理和切换。SaleSmartly就可以解决这个问题,让员工在一个平台上同时使用多个WhatsApp账号,不需要频繁地登录和退出,方便客服查看和回复所有的消息和通话。在SaleSmartl......
  • WhatsApp个人号、Business号、API号到底有什么区别
    WhatsApp作为全球苹果应用商店中用户下载量最多的社交网络应用,在全球有25亿的用户,每日活跃人数超过5亿人。很多人都以为WhatsApp就是一个软件,但是其实它是个家族,里面共有三个成员,分别是WhatsApp Messenger,WhatsApp Business和WhatsApp Business API。按照它们推出市场的时间来......
  • What's new in Pika v3.5.0
    时隔两年,Pika社区正式发布经由社区50多人参与开发并在360生产环境验证可用的v3.5.0版本,新版本在提升性能的同时,也支持了Codis集群部署,BlobDBKV分离,增加Exporter等新特性。我们将详细介绍该版本引入的重要新特性。1去除Rsync在v3.5.0版本之前,Pika使用Rsync工具......
  • isNaN(1/0) 返回值是false
    任何数值除以0都会导致错误而终止程序执行。但是在JavaScript中,会返回出特殊的值,因此不会影响程序的执行。比0大的数除以0,则会得到无穷大,所以js用Infinity来显示出来。也就是1/0得到的是Infinity。isNaN(1/0)返回的是false。但是isNaN(0/0)返回的就是true......
  • WhatsApp Business为什么会被封号?该如何解决
    目前,作为全球即时通讯领域的重要平台之一的WhatsApp已成为企业在营销和与客户沟通时的首选工具。但是长时间、高强度的营销行为很容易导致WhatsApp Business账户突然被封禁,无法再使用账号。即使后续再去进行申诉,要求官方解封该账户,也仍然需要等待一段时间。在这段时间里账号仍然是......
  • 3 ways light pollution harms the planet - and what we can do about it
    Lightpollutionnotonlyimpactstheenvironment,butourhealthtoo. ·Globallightpollutionhasincreasedby49%over25yearsto2017,newresearchshows,andtherealfiguremaybeevenhigher.·Itsimpactsarewide-ranging-withhumanhealth,thee......
  • Indoor air pollution: What causes it and how to tackle it
      Mostpeoplethinkofairpollutionassomethingthatcomesfromfactoriesormotorvehicles.However,didyouknowthattheairinsideyourhomeorplaceofworkcanalsobepolluted?Infact,indoorairpollutioncanbeevenmoreharmfultoyourhea......