fnPopup() 함수
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
function fnPopup(){
window.alert("이것은 alert 입니다");
let input = window.prompt("입력하세요 : ");
document.write(input);
let choice = window.confirm("당신의 선택은 ?");
if(choice === true)
window.alert("확인을 선택했습니다");
else
window.alert("취소를 선택했습니다");
}
</script>
</head>
<input type="button" value="alert test" onclick="fnPopup()"/>
</body>
</html>
fnEval1() 함수
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
function fnEval1(){
let ex1 = "50 * 2 + 3";
console.log(eval(ex1))
}
</script>
</head>
<input type="button" value="eval1 test" onclick="fnEval1()"/><br><br>
</body>
</html>
fnEval2() 함수
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
function fnEval2(){
let ex2 = "window.alert('안녕'); document.write('hello');";
console.log(eval(ex2));
}
</script>
</head>
<input type="button" value="eval2 test" onclick="fnEval2()"/><br><br>
</body>
</html>
fnParse() 함수
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
function fnParse(){
let num1 ="33";
let num2 ="22";
console.log(num1+num2);
console.log(parseInt(num1) + parseInt(num2));
console.log(parseInt("33abc")+5);
console.log(parseFloat("3.14")+5);
}
</script>
</head>
<input type="button" value="parse test" onclick="fnParse()"/><br><br>
</body>
</html>