Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

WON.dev

chapter04 : 객체 본문

WEB.JS/06.객체_JS

chapter04 : 객체

GAWON 2023. 5. 19. 17:41
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
//book객체 생성
var book = {
title : "자바스크입트의 정석",
price : 30000,
stock : 10
};

```
// price를 35000으로 수정하시오.    *객체 속성 수정
book.price = 35000;
document.write(book.price);

//salePrice 속성을 price의 90%로 새로 추가하시오.  *객체 속성 추가
//salePrice는 원래 없지만, 있었던 것처럼 작성하면 된다.
book.salePrice = book.price * 0.9;
document.write(book.salePrice);

//stock 속성을 제거 하시오.                     *객체 속성 삭제
delete book.stock;  // == delete (book.stock); 괄호도 사용 가능

document.write(book.price + "<br>");
document.write(book.price + "<br>");
document.write(book.salePrice + "<br>");
document.write(book.stock + "<br>");

```

</script>
</head>
<body>

</body>
</html>

'WEB.JS > 06.객체_JS' 카테고리의 다른 글

chapter06 : 생성자함수  (0) 2023.05.19
chapter05 : 객체  (0) 2023.05.19
chapter03 : 객체  (0) 2023.05.19
chapter02 : 객체  (0) 2023.05.19
chapter01 : 객체  (0) 2023.05.19