๐ป
JavaScript ์ ์ดํด - ์ค๋ธ์ ํธ(Object) ๋ณธ๋ฌธ
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>
๋ฐ์ํ
'KITRI > JAVASCRIPT' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
JavaScript ์ ์ดํด - [AJAX] ํ์ค ๋ต๊ธ ๋ฌ๊ธฐ(CRUD) (0) | 2020.07.16 |
---|---|
JavaScript ์ ์ดํด - [AJAX] XHR(XMLHttpRequest) (0) | 2020.07.16 |
JavaScript ์ ์ดํด - [AJAX] JSON ๊ฐ์ฒด ๋ค๋ฃจ๊ธฐ (0) | 2020.07.15 |
JavaScript ์ ์ดํด - JS/jQuery ์๋์์ฑ ํ๋ฌ๊ทธ์ธ ์ค์น (0) | 2020.07.14 |
JavaScript ์ ์ดํด - ๊ธฐ๋ณธ ๊ฐ๋ ๋ฐ ๋ฌธ๋ฒ/ ์ด๋ฒคํธ(Event) / ํจ์(Function) (0) | 2020.06.04 |
Comments