话说前端25,JavaScript的数据类型


分享兴趣,传播快乐,增长见闻,留下美好!

亲爱的您,这里是LearningYard新学苑。

今天小编为大家带来知识集|物流运输与配送管理(25),欢迎您的访问。

Share interests, spread happiness, increase knowledge, and leave a good legacy!

Dear you, this is The LearningYard Academy.

Today Xiaobian brings you the knowledge sharing of Knowledge Set| Logistics Transportation and Distribution Management (4), welcome to your visit.

Today, let's talk about six types of Javascript. Javascript is a language with weak variables. When we define a variable, we don't pay attention to its type. The data types of JavaScript language are composed of six types: string type, number type, Boolean type, null type, undefined type and object type. The first five types are basic data types, followed by extended data types. Next, the functions and usage of each data type are introduced in detail.

今天我们讲一下Javascript六大类型,Javascript是一个弱变量的语言,当我们定义一个变量的时候会不注重他的类型JavaScript语言的数据类型由字符串型、数字型、布尔型、null型、undefined型和对象型6大类型组成,前面5种为基本数据类型,后面扩展的数据类型,接下来详细地介绍每种数据类型的功能和使用方法。

Today, let's talk about six types of Javascript. Javascript is a language with weak variables. When we define a variable, we don't pay attention to its type. The data types of JavaScript language are composed of six types: string type, number type, Boolean type, null type, undefined type and object type. The first five types are basic data types, followed by extended data types. Next, the functions and usage of each data type are introduced in detail.

字符串是用Unicode字符、数字、标点符号等组成的的唯一序列,在JavaScript代码之中则用于表示JavaScript数据类型,字符串由单引号或双引号包裹,双引号定界的字符串中可以再包含单引号,单引号定界的字符串中也可以再包含双引号。

A string is a unique sequence composed of Unicode characters, numbers, punctuation marks, etc. In JavaScript code, it is used to indicate JavaScript data type. The string is wrapped by single quotation marks or double quotation marks. The string delimited by double quotation marks can contain single quotation marks again, and the string delimited by single quotation marks can also contain double quotation marks again.

在JavaScript代码中,数字型变量用的非常广泛,它也是最为基本类型,但它与其他语言的数字类型不同,它并不区别整数型和浮点型,而是统称为浮点型,这种类型既可以表示整数,小数,同时还能使用指数形式可以表示更大或更小的值。

In JavaScript code, numeric variable is widely used, and it is also the most basic type. However, it is different from numeric types in other languages. It does not distinguish between integer type and floating point type, but is collectively called floating point type. This type can represent both integers and decimals, and can also represent larger or smaller values in exponential form.

与数字类型不同,布尔型变量的值只有固定两种表示,一种是true,另一种是false,前者真,后者假,如果用数字表示,那么,true用1来表示,false用0来表示,布尔型值来源于逻辑性运算符,常用于控制流程。

Different from numeric types, there are only two fixed representations of the value of Boolean variables, one is true, the other is false, the former is true and the latter is false. If it is represented by numbers, then, true is represented by 1, and false is represented by 0. Boolean values are derived from logical operators and are often used in control processes.

在JavaScript代码中,空值型是特殊类型,它只有一个值,就是null,当引用一个未定义对象时,将返回一个null,严格意义上来说,null本质上是一个对象类型,是一个空指针对象类型。

In JavaScript code, null type is a special type. It has only one value, which is null. When an undefined object is referenced, it will return a null. Strictly speaking, null is essentially an object type and a null pointer object type.

与Null相同,Undefined也是只有一个undefined值,在编写JavaScript代码时,如果定义了一个变量,没有给它赋值,那么,这个变量返回undefined值,这也是变量默认的,与Null型不同之处在于,Null是一个空值,而Undefined表示无值。

Same as Null, Undefined has only one Undefined value. When writing JavaScript code, if a variable is defined and it is not assigned a value, then, this variable returns an undefined value, which is also the default of the variable. The difference from Null is that Null is a null value, while undefined means no value.

今天的分享就到这里了。如果您对今天的文章有什么独特的想法,欢迎评论留言,让我们相约明天,祝您今天过得开心快乐!

That's it for today's sharing. If you have any unique ideas for today's article, please leave a comment, let us meet tomorrow, I wish you a happy day!



翻译:Google翻译

本文由LearningYard新学苑原创,部分图片文字来自网络,如有侵权请联系。

文字&排版|李仕阳

审核|李焕

展开阅读全文

页面更新:2024-03-13

标签:数据类型   浮点   布尔   整数   字符串   变量   对象   类型   代码   数字

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号

Top