functiontest(){let i =10let j =1.1let x ='etoak'let y =truelet z =null//直接从页面输出document.write(`${i}+${j}=${i+j}<br>`)document.write(`${i}+${x}=${i+x}<br>`)document.write(`${i}+${y}=${i+y}<br>`)document.write(`${i}+${z}=${i+z}<br>`)document.write(`${j}+${x}=${j+x}<br>`)document.write(`${j}+${y}=${j+y}<br>`)document.write(`${j}+${z}=${j+z}<br>`)document.write(`${y}+${x}=${y+x}<br>`)document.write(`${z}+${x}=${z+x}<br>`)}//运行结果/**10+1.1=11.110+etoak=10etoak10+true=1110+null=101.1+etoak=1.1etoak1.1+true=2.11.1+null=1.1true+etoak=trueetoaknull+etoak=nulletoak
*/
循环语句
function test(){for(let a =1;a<=9;a++){console.log(a )}}
测试语法
<!DOCTYPEhtml><htmllang="zh-CN"><head><metacharset="UTF-8"><title>测试</title></head><bodyonload="etoak('hello','你好')"><script>//此处函数中传递的为形参,形参标识符可以随意书写,注意避免五种字符functionetoak(arg1,arg2){alert(`${arg1}world,${arg2}世界~~`)//注意常量尽量全部使用大写constSEASON=3if(SEASON>=1&&SEASON<=3){console.log('春天来了')}elseif(SEASON>=4&&SEASON<=6){console.log('夏天来了')}elseif(SEASON>=7&&SEASON<=9){console.log('秋天来了')}elseif(SEASON>=10&&SEASON<=12){console.log('冬天来了')}let i =10let j =1.1let x ='etoak'let y =truelet z =null//直接从页面输出document.write(`${i}+${j}=${i+j}<br>`)document.write(`${i}+${x}=${i+x}<br>`)document.write(`${i}+${y}=${i+y}<br>`)document.write(`${i}+${z}=${i+z}<br>`)document.write(`${j}+${x}=${j+x}<br>`)document.write(`${j}+${y}=${j+y}<br>`)document.write(`${j}+${z}=${j+z}<br>`)document.write(`${y}+${x}=${y+x}<br>`)document.write(`${z}+${x}=${z+x}<br>`)//在页面上使用document.write()来输出九九乘法表let str =''for(let a =1;a<=9;a++){for(let b =1;b<=a;b++){str +=`${b}*${a}=${b*a}\t`}str +='<br />'}document.write(str)}</script></body></html>