๐Ÿ’ป

JavaScript ์˜ ์ดํ•ด - ์˜ค๋ธŒ์ ํŠธ(Object) ๋ณธ๋ฌธ

KITRI/JAVASCRIPT

JavaScript ์˜ ์ดํ•ด - ์˜ค๋ธŒ์ ํŠธ(Object)

๋˜ํšจ๋‹ˆ 2020. 6. 5. 12:41

 

10_Object.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
	//์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์˜ ์ž๋ฃŒํ˜•๋“ค์€ ๋ชจ๋‘ ๊ฐ์ฒด์ด๋‹ค
	//1. number ๊ฐ์ฒด
	var su = 10;
	var value = new Number(20);
	document.write(su + "<br/>" + value + "<br/><br/>");
	
	var num = 123.45678;
	document.write(num.toFixed(3) + "<br/>"); //123.457
	document.write(num.toPrecision(10) + "<br/>"); 	//123.45678
	document.write(num.toPrecision(5) + "<br/>");		//123.46
	document.write(Number.MAX_VALUE + "<br/>" + Number.MIN_VALUE + "<br/><br/>");
	
	//2.Math ๊ฐ์ฒด
	document.write("์ ˆ๋Œ€๊ฐ’: " + Math.abs(-15) + "<br/>");
	document.write("์ตœ๋Œ€๊ฐ’: " + Math.max(10,15,150) + "<br/>");
	document.write("์ตœ์†Œ๊ฐ’: " + Math.min(-1,-2,0,7) + "<br/>");
	document.write("๋ˆ„์Šน: " + Math.pow(2,3) + "<br/>");
	document.write("๋žœ๋ค: " + Math.random() + "<br/>");
	
	//3. String ๊ฐ์ฒด - ๋ฌธ์ž, ๋ฌธ์ž์—ด
	var abc = "์•ˆ๋…•ํ•˜์„ธ์š”";
	var xyz = new String("๋ฐ˜๊ฐ€์›Œ์š”");
	document.write(abc + "<br/>" + xyz + "<br/>");
	
	var str = "ABCDEFGHIJ";
	document.write(str.substring(6) + "<br/>");
	document.write(str.substring(2,8) + "</br><br/>");
	
	var email = "hong@naver.com";
	document.write(email.toLowerCase() + "<br/>");
	document.write(email.toUpperCase() + "<br/>");
	document.write(email.indexOf("@") + "<br/>")
	document.write(email.charAt(2) + "<br/>");	
	
	var result = "abc, def, 123";
	var array = result.split(",");
	for(var i=0; i<array.length; i++){
		document.write(array[i] + "<br/>");
	}
</script>
</head>
<body>

</body>
</html>

 

 

 

11_Object.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
		//4. Array ๊ฐ์ฒด
		var su = [1,2,3,4];
		var strArray = new Array("์‚ฌ๊ณผ", "๋ฐ”๋‚˜๋‚˜", "๋”ธ๊ธฐ");

		document.write(su + "<br/>" + strArray + "<br/>");
		document.write(su.concat(strArray) + "<br/>");
		document.write(strArray.join("/") + "<br/>");
		document.write(strArray.slice(1) + "<br/><br/>");
	
		
		//5. Date ๊ฐ์ฒด๋Š” JSTL ํ•  ์˜ˆ์ •
		
		//6. Global(๋‚ด์žฅ ํ•จ์ˆ˜)
		var su = "77";
		document.write(parseInt(su) + 100);
		
		//์ž๋ฐ”ํ•˜๊ณ  ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๋ฐ์ดํ„ฐ ์ „๋‹ฌ์‹œ ํ•œ๊ธ€, ํŠน์ˆ˜๋ฌธ์ž ์ฒ˜๋ฆฌ 
		var url = "#!eiuf+-0()";
		var a = encodeURI(url);
		var b = decodeURI(a);
		document.write("<br/>" + a + "</br>" + b);
		
		var c = encodeURIComponent(url);
		var d = decodeURIComponent(c);
		document.write("<br/>" + c + "</br>" + d);
		
		var str = "์•ˆ๋…•ํ•˜์„ธ์š”";
		var x = encodeURI(str);
		var y = decodeURI(x);
		document.write("<br/>" + x  + "<br/>" + y);
</script>
</head>
<body>
</body>
</html>

๋ฐ˜์‘ํ˜•
Comments