1.string
//1.string和nubmer
console.log('z' + 6)//输出为'z6'
//string + number = string
//2.string和boolean
console.log('z' + false)//输出为'zfalse'
//string + false= string
//3.string和undefined
console.log('z' + undefined)//输出为'zundefined'
//string + undefined= string
//4.string和NaN
console.log('z' + NaN)//输出为'aNaN'
//string + NaN= string
//5.string和null
console.log('z' + null)//输出为'anull'
//string + null= string
字符串的优先级是最高的,当字符串和其他类型的数据做“+”运算时,就会把他们都转换成字符串在进行拼接
2.number
//1.number和boolean
console.log(6 + true)//输出为7
//number+ boolean= number
//2.number和undefined
console.log(6 + undefined)//输出为'NaN'
//number+ undefined= NaN
//3.number和NaN
console.log(6 + NaN)//输出为'NaN'
//number+ NaN= NaN
//4.number和null
console.log('z' + null)//输出为6
//number + null= number
虽然number和NaN输出的结果与number和undefined的结果是一样的,不代表他们是相等的,但是null和undefined是相等的
3.boolean
//1.boolean和boolean
console.log(true + true)//输出为2
//boolean+ boolean= number
//2.boolean和undefined
console.log(true + undefined)//输出为'NaN'
//boolean+ undefined= NaN
//3.boolean和NaN
console.log(6 + NaN)//输出为'NaN'
//boolean+ NaN= NaN
//4.boolean和null
console.log(true + null)//输出为1
//boolean+ null= number
注:null在和bnmber或者boolean做运算时,会被当做0来使用,但null不等于0.