「JavaScript」if文の===比較のサンプル

書式
変数名===値
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<script>
const xx = 5;
// ===で比較
if (xx === 5) {
console.log("true 111");
} else {
console.log("false 222");
}
</script>
<script> const xx = 5; // ===で比較 if (xx === 5) { console.log("true 111"); } else { console.log("false 222"); } </script>
<script>
    const xx = 5;

    // ===で比較
    if (xx === 5) {
        console.log("true 111"); 
    } else {
        console.log("false 222");
    }
</script>

実行結果
true 111

JavaScript

Posted by arkgame