JavaScript字符串拼接

JavaScript字符串拼接

 

 JavaScript字符串拼接

 

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var sName = '李四';
        var iAge = '20';
        var sSex = '男';
        var sResult = sName + sSex;
        alert(sResult)
        // 字符串和数字进行拼接,底层自动把数字类型转换成字符串,这种操作叫隐式类型转换
        sResult = sName + iAge;
        alert(sResult);
        // +=
        iAge += sSex
        alert(iAge)
    </script>
</head>
<body>
    
</body>
</html>

 

上一篇:2021-03-23


下一篇:c++ 结构体 数组 指针 函数的遍历(笔记)