<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
var vscope = "global";
function fscope () {
alert(vscope);
}
fscope();
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
var vscope = "global";
function fscope () {
alert(vscope);
}
function fscope2 () {
alert(vscope);
}
fscope();
fscope2();
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
var vscope = 'global';
function fscope() {
var lv = 'local val';
alert(lv);
}
fscope();
alert(lv);
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
var vscope = 'global';
function fscope() {
var vscope = 'local';
alert('함수 안' + vscope);
}
fscope();
alert('함수 밖' + vscope);
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
var vscope = 'global';
function fscope() {
vscope = 'local';
alert ('함수 안' + vscope);
}
fscope();
alert('함수 밖' + vscope);
</script>
</body>
</html>