2024-10-15

<!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>
const person = {
name : "홍길동",
eat : function(food) {
document.write(`${this.name} 님이 ${food} 를 먹습니다.`);
// this : 객체의 자기 자신 호출법
}
}
document.write(`이 름 : ${person.name} <br>`);
person.eat("빵");
</script>
</head>
<body>
</body>
</html>

'JavaScript > 기초 내용 정리' 카테고리의 다른 글
| JavaScript(BOM)_02 (0) | 2024.10.15 |
|---|---|
| JavaScript(BOM)_01 (0) | 2024.10.15 |
| JavaScript(Object)_01 (0) | 2024.10.15 |
| JavaScript(Function)_Exam_01 (0) | 2024.10.14 |
| JavaScript(Function)_04 (0) | 2024.10.14 |