console.group('数字操作');
// 浮点数值的内存空间是整数的两倍;
// 会alert出来3e-7;从小数点后面6个0开始,就用科学计数法了;
//alert(0.0000003);
// 这样会正常输出
console.log(0.000003);
// 输出:0.30000000000000004
console.log(0.1+0.2);
// 输出0.3
console.log(0.15+0.15);
// NaN
console.log(0/0);
// Infinity
console.log(1/0);
// -Infinity
console.log(-1/0);
// NaN的任何操作都返回NaN
console.log(NaN*0);
// NaN与NaN不相等,与谁都不等;
console.log(NaN==NaN);
// Infinity
console.log(Infinity+Infinity);
// Infinity
console.log(Infinity*Infinity);
// NaN
console.log(-Infinity+Infinity);
// -Infinity
console.log(-Infinity-Infinity);
// -Infinity
console.log(-Infinity*2);
console.groupEnd();
console.group('typeof 操作符');
var str;
// 输出undefined
console.log(typeof str);
// 没有定义的变量,也输出undefined
console.log(typeof str1);
console.log(typeof 1);
console.log(typeof 'a');
console.log(typeof true);
// 输出为number
console.log(typeof NaN);
// 输出为number
console.log(typeof Infinity);
// 输出为number
console.log(typeof -Infinity);
// 输出为undefined
console.log(typeof undefined);
console.log(typeof {});
console.log(typeof new Date());
// 输出为object
console.log(typeof []);
// 输出为object
console.log(typeof null);
console.groupEnd();
// 转为false的内容;
console.group('转为false');
console.log(Boolean(0));
console.log(!!'');
console.log(!!NaN);
console.log(!!null);
console.log(!!undefined);
console.groupEnd();
console.group('isNaN函数');
// 返回true,的确不是数字
console.log(isNaN(NaN));
// 返回false
console.log(isNaN(10));
console.log(isNaN('10'));
// 返回true
console.log(isNaN('blue'));
// 返回false,true可以变成数字1
console.log(isNaN(true));
console.log(isNaN(false));
// 输出2
console.log(true+1);
// 输出false,Infinity也算是数字
console.log(isNaN(Infinity));
console.groupEnd();

数字操作 转为false的类型 typeof操作符 isNaN函数的更多相关文章

  1. Python 学习 第一篇:数据类型(数字,集合,布尔类型,操作符)

    Python语言最常用的对象是变量和常量,常量的值是字面意思,其值是不可变的,变量的值是可变的,例如,123,"上海"是常量,而a=1,a=2,其中a是变量名.内置的核心数据类型有 ...

  2. typeof操作符和instanceof操作符的区别 标签: JavaScript 2016-08-01 14:21 113人阅读 评论(

    typeof主要用于检测变量是不是基本数据类型 typeof操作符是确定一个变量是字符串.数值.布尔类型,还是undefined的最佳工具.此外,使用typeof操作符检测函数时,会返回"f ...

  3. pyton3的数字操作你都会用吗?

    '''数字数据类型用于存储数值.数据类型是不允许改变的,这就意味着如果改变数字数据类型的值,将重新分配空间. 1.del(用于删除一些数字对象的引用) 2.整形(int)通常被称为是整形或者整数,是正 ...

  4. Hive 文件格式 & Hive操作(外部表、内部表、区、桶、视图、索引、join用法、内置操作符与函数、复合类型、用户自定义函数UDF、查询优化和权限控制)

    本博文的主要内容如下: Hive文件存储格式 Hive 操作之表操作:创建外.内部表 Hive操作之表操作:表查询 Hive操作之表操作:数据加载 Hive操作之表操作:插入单表.插入多表 Hive语 ...

  5. typeof操作符返回一个字符串,表示未经计算的操作数的类型。

    typeof操作符返回一个字符串,表示未经计算的操作数的类型.   语法 typeof运算符后跟操作数: typeof operand or typeof (operand) 参数 operand 是 ...

  6. 谨慎 mongodb 关于数字操作可能导致类型及精度变化

    1.问题描述 最近有一个需求,更新Mongo数据库中 原料 集合的某字段价格,更新后,程序报错了,说长度过长了,需要Truncation. 主要错误信息如下: FormatException: An ...

  7. JavaScript类型检测, typeof操作符与constructor属性的异同

    *#type.js function Person(name, age) { this.name = name; this.age = age; } var d = {an: 'object'}; v ...

  8. javaScript--进阶1--数据类型、操作符

    一.JS基础知识背景 1.1 弱类型脚本语言 脚本语言是:弥补编译语言的不足而存在的,作为补充语言,不用编译,解析一行执行一行. 弱类型语言:简单理解定义一个变量,可以有多种数据类型.(var tem ...

  9. JS 数据类型入门与typeof操作符

    标准的数据类型划分: 基本类型: number(数字).string(字符串).undefined.boolean(布尔值).null(空对象) //空对象与非空对象,最大的区别就是不能进行属性操作 ...

随机推荐

  1. Chapter 1 First Sight——4

    Charlie gave me an awkward, one-armed hug when I stumbled my way off the plane. 当我让我蹒跚的从飞机上下来,查理斯单手给 ...

  2. 使用Visual Studio 2008创建你的第一个Windows Mobile程序介绍

    使用Visual Studio 2008创建你的第一个Windows Mobile程序介绍 Windows MobileMobileWindowsMicrosoftWinForm 介绍 Microso ...

  3. PAT (Advanced Level) 1022. Digital Library (30)

    简单模拟题. 写的时候注意一些小优化,小心TLE. #include<iostream> #include<cstring> #include<cmath> #in ...

  4. PAT (Advanced Level) 1010. Radix (25)

    撸完这题,感觉被掏空. 由于进制可能大的飞起..所以需要开longlong存,答案可以二分得到. 进制很大,导致转换成10进制的时候可能爆long long,在二分的时候,如果溢出了,那么上界=mid ...

  5. particles.js 一个非常酷炫的粒子动画库

    GIT 地址:https://github.com/VincentGarreau/particles.js/ 效果:

  6. UIScroll和UIPickView

    .h #import <UIKit/UIKit.h> #define WIDTH self.view.frame.size.width #define HEIGHT self.view.f ...

  7. CentOS 5.8 x64 安装TomCat

    简单记录一下...虽然安装很简单... 首先下载配置安装 jdk http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u25-do ...

  8. CDOJ 1268 Open the lightings

    组合数学题.好难啊,请教了Xiang578大神&&看了他题解才会的...... 甩上题解链接:http://blog.csdn.net/xinag578/article/details ...

  9. 一次性能优化,tps从400+到4k+

    项目介绍 路由网关项目watchman ,接收前端http请求转发到后端业务系统,功能安全验证,限流,转发. 使用技术:spring boot+ nreflix zuul,最开始日志使用slf4j+l ...

  10. storybody中页面跳转

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ if ([segue.destinationViewCont ...