<p>A = <span class="a"></span></p>
<p>B = <span class="b"></span></p>
// 宣告變數 a
var a = 10;

if(true){
  //  在if(block scope)中宣告變數 b
  var b = 20;
}

// 輸出: A = 10
$(".a").text(a);
// 輸出: B = 20
$(".b").text(b);

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js