js内置数据类型

JS 中分为七种内置类型,七种内置类型又分为两大类型:基本类型和对象(Object)。

 

基本类型有六种: number , string , boolean , null , undefined , symbol 。

 

其中 JS 的数字类型是浮点类型的,没有整型。并且浮点类型基于 IEEE 754标准实现,在使用中会遇到某些 Bug。 NaN  也属于  number  类型,并且  NaN  不等于自身。

 

对于基本类型来说,如果使用字面量的方式,那么这个变量只是个字面量,只有在必要的时候才会转换为对应的类型

<template> <section class="p-10"> </section></template><script> export default { mounted() { let a = 111; // 这只是字面量,不是 number 类型 a.toString(); // 使用时候才会转换为对象类型 } }; </script>

 

对象(Object)是引用类型,在使用过程中会遇到浅拷贝和深拷贝的问题

<template> <section class="p-10"> <el-button type="danger" @click="get()">点击</el-button> </section></template><script> export default { methods: { get() { let a = { name: CEH }; let b = a; b.name = JZ; console.log(a); console.log(b); } } }; </script>

 

嗯,就酱~~

https://www.cnblogs.com/chuhui/archive/2018/12/03/10060071.html

相关文章