웹 개발

ECMAScript 5 객체 생성

노루아부지 2019. 8. 17. 00:01

ECMAScript 5 객체 생성

 - HTML5와 함께 출현한 javascript 표준안을 ECMAScript 5라고 부른다.

 - ECMAScript 5는 IE 8 이하에서는 지원하지 않는다.

 - 생성자는 틀은 기반으로 객체를 찍어내 객체를 생성하지만 create는 기존에 있던 객체를 복제하고 새로운 속성을 추가해 객체를 생성한다.

method 이름

Object.create()

 

1. create(원본이 되는 객체, 추가하고자 하는 속성)

<script>
	var aaa = Object.create({}, {
		name: {value: 'masami', enumerable: true},
		gender: {value: 'female', enumerable: true}
	});

	var bbb = Object.create(aaa, {
		region: {value: 'Seoul', enumerable: true}
	});
</script>

 

이렇게 사용하면 bbb에서 name과 gender를 사용할 수 있다. (상속)

728x90

'웹 개발' 카테고리의 다른 글

javascript 상속  (0) 2019.08.17
ECMAScript 5 객체 속성 추가  (0) 2019.08.17
html/css - table 구조에서 열(column)단위로 숨기기  (2) 2019.08.17
jquery ui class  (0) 2019.08.16
web page performance  (0) 2019.08.16
loading