Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS 的基本数据类型。 #1

Open
artdong opened this issue Jul 4, 2019 · 4 comments
Open

JS 的基本数据类型。 #1

artdong opened this issue Jul 4, 2019 · 4 comments
Labels
js javascript

Comments

@artdong
Copy link
Collaborator

artdong commented Jul 4, 2019

介绍一下 JS 的基本数据类型。

@artdong artdong added the js javascript label Jul 4, 2019
@artdong
Copy link
Collaborator Author

artdong commented Jul 5, 2019

JS有 5 种基本数据类型(原始类型),即 Undefined、Null、Boolean、Number 和 String。

Undefined 类型只有一个值,即 undefined。
Null 类型只有一个专用值 null,即它的字面量。
Boolean 类型有两个值 true 和 false (即两个 Boolean 字面量)。
Number 类型既可以表示 32 位的整数,还可以表示 64 位的浮点数。安全整数范围为 -(253 - 1)到 253 - 1 之间的整数。
String 类型的字符串字面量是由双引号(")或单引号(')声明的。

@alonesuperman
Copy link

alonesuperman commented Jul 5, 2019

Symbol
BigInt

see mdn for detail

@artdong
Copy link
Collaborator Author

artdong commented Jul 10, 2019

JS 7 种基本数据类型(原始类型),即 (Undefined、Null、Boolean、Number 、String) + (Symbol、BigInt)和 3种引用数据类型:对象(Object)、数组(Array)、函数(Function)。

基本类型值:指的是保存在栈内存中的简单数据段。

引用类型值:指的是那些保存在堆内存中的对象。变量中保存的实际上只是一个指针,这个指针指向内存堆中实际的值。

注:Symbol 是 ES6 引入了一种新的原始数据类型,表示独一无二的值; BigInt即是第七种基本类型,V8引擎v6.7 默认启用对 BigInt 的支持。

Symbol用法

语法

Symbol (value)

eg.

let a=Symbol ("welcome");
console.log(a); //输出 Symbol(welcome)

BigInt用法

语法

BigInt(value) || 数字后面加n;

eg.

let b1 = BigInt(10);
let b2 = 10n;
console.log(b1,b2); //输出 10n 10n

@artdong artdong pinned this issue Jul 11, 2019
@artdong artdong unpinned this issue Jul 11, 2019
@artdong artdong added this to done in fe-interview Jul 26, 2019
@my-code-store
Copy link

es6一共7种数据类型
Number:表示32位的整数和64位的浮点数
Undefined:只有一个值是Undefined
String:字符串类型
Boolean:有true和false两个值
Symbol:创建一个唯一的值Symbol('test') === Symbol('test')的结果是false
BigInt:当数值的大小超过最大安全数时,无法判断数值的小,BigInt可以解决,只需在数值后加'n'就可以了例如:9009999999999999229 == 9009999999999999329 结果是true;9009999999999999229n == 9009999999999999329n 结果是false

@artdong artdong changed the title 介绍一下 JS 的基本数据类型。 JS 的基本数据类型。 Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
js javascript
Projects
Development

No branches or pull requests

3 participants