본문 바로가기

먹고살거/KPI

[자바스크립트]4-3.내장객체(Array)

4-3.자바스크립트 내장객체(Array)


배열 = 하나의 변수에 여러가지 데이터를 저장


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title> new document </title>

<meta http-equiv="content-type" content="text/html; charset=utf-8" />

<script type="text/javascript">

//<![CDATA[

//배열 = 하나의 변수에 여러가지 데이터를 저장

/*

var arrNum = new Array(10,20,30,30);

console.log(arrNum[1]);


arrNum[4] = 50;

arrNum[5] = 60;


console.log(arrNum.length);

console.log(arrNum[arrNum.length-1]);



arrNum=[10,20,30,40,50,60,70]

console.log(arrNum[5]);

arrNum[5]=1000;

*/


//요일만들기

var today = new Date();

var num = today.getDay();


var yoil=["일요일","월요일","화요일","수요일","목요일","금요일","토요일"];


console.log(yoil[num]);


//요일별로 나오게하기

//document.write(yoil[0]);

//document.write(yoil[1]);

for(var i=0; i<yoil.length; i++){

document.write(yoil[i] + "<br/>");

}


//이달의 전체 일수를 구해보세요.

var totDay = [31,28,31,30,31,30,31,31,30,31,30,31];

var nowMonth = today.getMonth();

document.write(totDay[nowMonth] + "<br/>");

//윤년구하기

var nowYear = today.getFullYear();

var nowYear4 = nowYear%4 == 0 && nowYear%100 != 0 || nowYear%400 == 0;

//console.log(nowYear4);


if(nowYear%4 == 0 && nowYear%100 != 0 || nowYear%400 == 0){

totDay[1]=29;

}

document.write(totDay[nowMonth] + "<br/>");


//이번달 달력 구하기





//]]>

</script>

</head>

<body>


</body>

</html>