js的基本类型
- number
- string
- boolean
- undefined
- null
- symbol
- Object(array function)
可以用typeof查询, NaN(number),null(Object)
浮点数的运算
先转换为整数,再运算,再转化为小数
一个值不等于它本身:NaN
null 和undefined区别
定义一个变量,不赋值,就是undefined
null是赋了一个空值
falsely 和 truthy
faksely :
false 0 ‘’ “” null undefined NaN (空数组、空对象 不在列表里)
if(!word || word.length !== 0)
truthy:
“0”, [], {}
值传递和饮用传递
js中,六个基本类型(number string boolean null undefined symbol)是值传递
如果要改变toatl的值:
let total = 2;
function calc(total) {
total = total * 2;
return total;
}
total = calc(total);