当前位置:网站首页>基础数据类型和复杂数据类型
基础数据类型和复杂数据类型
2022-06-27 17:34:00 【编程奥特曼.】
let声明的是变量,且可以变化的量,如果重复赋值,且后者会覆盖前者
const声明的常量,且不会变化的量,不能重复赋值,且声明的时候必须赋值
0.1 + 0.2 == 0.30000000000000004 为啥?
因为机器语言转成二进制,二进制在进行计算的时候出现了精度缺失,
七种基础数据类型:
1、Number:数值型 数据计算的范围是22013 ~ -22013
2、String:字符串,js可以识别+号两侧,但凡有一侧有+号 那就是拼接
3、Boolean:只有八种会转为false,其他的都为true,分别是Boolean(0),Boolean(0n),Boolean(undefined),
Boolean(null),Boolean(false),Boolean(" "),Boolean(NaN),Boolean( ),主要用于做判断处理
4、Null:空值 举例:有一块地名义上是我的,但是地上没有物品,不占空间是null,
5、undefined: 举例:有一块地名义上是我的,但是地上有我的物品,占空间是undefined,
6、Symbol:独一无二的值
7、Bigint:超大整数,使用的时候后面必须加n
复杂数据类型:
arr[] ,object{},函数function,内置对象:window ,document(Dom), Math数学对象 ,Date日期对象,除了基础类型以外的,其它都属于复杂数据类型
数组可以存放多条数据,序号从0开始数,而lengrh是从1开始数的,取值方式似arr[]
普通对象/实例对象 { } 是通过键值对的形式去存储,键名:键值,取值方式1:obj点,且点后面不能跟字符串和数字,字符串和数字必须要用中括号包裹,取值方式2:obj[" "] ,如果取值的时候中括号内不带引号,会率先识别为是不是变量
什么是栈内存和堆内存?
基础数据类型存的数据会存到栈内存中,复杂数据类型存的数据会存到堆内存中,
那么它俩为什么不相等呢? 原因是因为: 打个比方arr存的数据会存到13栋1307间,而arr1存的数据会存到14栋1307间,所有说它们的内存地址不相同,就不会相等
let arr = [1,2,"雀雀",true]
let arr1 = [1,2,"雀雀",true]
console.log(arr == arr1); //false
如何修改和新增普通对象里的值
let age = "age"
let obj = {
name:"周杰伦",
age:18,
"abc" :"123",
10:123,
"10":"你好",
}
// 修改
obj.name = "杰伦哥"
// 新增
obj.hobby = "爱打篮球"
// 修改值
obj[10] = "ABC"
console.log(obj);
console.log(obj.length);
边栏推荐
- 全面解析零知识证明:消解扩容难题 重新定义「隐私安全」
- Two methods of MySQL database login and logout
- 工作流自动化 低代码是关键
- External interrupt experiment based on stm32f103zet6 library function
- 驾驭一切的垃圾收集器 -- G1
- CMS 执行的七个阶段
- maxwell 报错(连接为mysql 8.x)解决方法
- DFS and BFS simple principle
- Gartner聚焦中国低代码发展 UniPro如何践行“差异化”
- Current market situation and development prospect forecast of the global ductless heating, ventilation and air conditioning system industry in 2022
猜你喜欢

Core dynamic Lianke rushes to the scientific innovation board: with an annual revenue of 170million yuan, Beifang Electronics Institute and Zhongcheng venture capital are shareholders

Running lantern experiment based on stm32f103zet6 library function

Bit.Store:熊市漫漫,稳定Staking产品或成主旋律

数据分析师太火?月入3W?用数据告诉你这个行业的真实情况

Jinyuan's high-end IPO was terminated: it was planned to raise 750million Rushan assets and Liyang industrial investment were shareholders

基于STM32F103ZET6库函数跑马灯实验

New Zhongda chongci scientific and Technological Innovation Board: annual revenue of 284million and proposed fund-raising of 557million

Comprehensively analyze the zero knowledge proof: resolve the expansion problem and redefine "privacy security"

华大单片机KEIL报错_WEAK的解决方案

Row to column and column to row in MySQL
随机推荐
什么是SSR/SSG/ISR?如何在AWS上托管它们?
Market status and development prospect forecast of global 4-methyl-2-pentanone industry in 2022
Erreur Keil de Huada Single Chip Computer La solution de Weak
电脑安全证书错误怎么处理比较好
一对一关系
让单测变得如此简单 -- spock 框架初体验
基于STM32F103ZET6库函数按键输入实验
高收益银行理财产品在哪里看?
深度学习和神经网络的介绍
openssl客户端编程:一个不起眼的函数导致的SSL会话失败问题
Keras深度学习实战(12)——面部特征点检测
Bit.Store:熊市漫漫,稳定Staking产品或成主旋律
Market status and development prospect forecast of global handheld ventilator industry in 2022
脉脉热帖:为啥大厂都热衷于造轮子?
华大单片机KEIL报错_WEAK的解决方案
Vs code runs "yarn run dev" and reports "yarn": the file XXX cannot be loaded
广发期货开户安全吗?
Teach you how to install Oracle 19C on Windows 10 (detailed picture and text with step on pit Guide)
Google Earth Engine(GEE)——ImageCollection (Error)遍历影像集合产生的错误
MySQL读取Binlog日志常见错误和解决方法