HTML 2일차 지역변수, 전역변수

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>JSP Test</title>
</head>
<body>

<script type="text/javascript">
money = 1146;

function test()
{
var money = 1;
document.write("$ "+money+"<br>");
document.write(this.money+"원 <br>");
}

test();
</script>

</body>
</html>


result)

댓글 없음: