1.banana.png"
3. <script src="name.js">추가 작성</script>
4. <a href="javascript:자바스크립트 코드">링크</a>
document.write("<h3>Welcome!<h3>");
상수의 종류 :
8진수 : 0으로 시작 16진수 : 0x로 시작. 문자열 : “” | ‘’ 으로 묶음. NaN==수가 아님을 뜻함(ex.parseInt(”abc”))
<!DOCTYPE html>
<html>
<head>
<title>함수 만들기</title>
<script>
function ggd(n){
var m=parseInt(n);
if(isNaN5(m)||m<1||m>9){
alert("잘못입력하셨습니다");
return;
}
for(var i=1;i<=9;i++){
document.write(m+'x'+i+'='+m*i+'<br>');
}
}
</script>
</head>
<body>
<h3>구구단 출력 함수 만들기</h3>
<hr>
<script>
var n=prompt("구구단 몇 단을 원하세요","");
ggd(n);
</script>
</body>
</html>
| 연산자 | 이름 | 비교방식 |
|---|---|---|
== | 동등 연산자 | 타입이 달라도 자동 형변환에서 값만 비교 |
=== | 일치 연산자 | 타입까지 같아야 true, 형변환 없음 |
console.log(5=="5"); //true
console.log(5==="5"); //false
console.log(0==false); //true
console.log(0===false); //false
console.log(null == underfined); //true
console.log(null === underfined); //false
console.log("313" == 313); //true
console.log("313" === 313); //false
var plots=[1,2,3,4,5]; 형식으로 만들거나 new Array()로도 만들 수 있음
<!DOCTYPE html>
<html>
<head>
<title>new Object()로 사용자 객체 만들기</title>
<script>
function inquiry(){return this.balance;}
function deposit(money){this.balance+=money;}
function withdraw(money){this.balance-=money;return money;}
var account=new Object();
account.owner="황기태";
account.code="111";
account.balance=35000;
account.inquiry=inquiry;
account.deposit=deposit;
account.withdraw=withdraw;
</script>
</head>
<body>
<h3>new Object()로 사용자 객체 만들기</h3>
<hr>
<script>
document.write("account : ");
document.write(account.owner+",");
document.write(account.code+",");
document.write(account.balance+"<br>");
account.deposit(10000); document.write(account.inquiry()+"<br>");
account.withdraw(5000); document.write(account.inquiry()+"<br>");
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>new Object()로 사용자 객체 만들기</title>
<script>
var account={
owner:"황기태",
code:"111",
balance:35000,
inquiry:function(){return this.balance;},
deposit:function(money){this.balance+=money;},
withdraw:function(money){this.balance-=money;return money;}
};
</script>
</head>
<body>
<h3>new Object()로 사용자 객체 만들기</h3>
<hr>
<script>
document.write("account : ");
document.write(account.owner+",");
document.write(account.code+",");
document.write(account.balance+"<br>");
account.deposit(10000); document.write(account.inquiry()+"<br>");
account.withdraw(5000); document.write(account.inquiry()+"<br>");
</script>
</body>
</html>