<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>자바스크립트 객체 생성</title>
<script>
function Person(name,age,addr){
	this.name=name
	this.age=age
	this.addr=addr
}
</script>
</head>
<body>
	<script>
		hong = new Person("홍",23,"서울시")	
	    alert(hong.name+","+hong.age+","+hong.addr)
	</script>
</body>
</html>

 

자바스크립트는 객체지향 언어로 위와같이 함수를 통해 객체를 생성할 수 있다.

하지만 클래스의 개념이 없는 프로토타입 기반 언어이다. 

 

프로토타입의 몇가지 특징에 대해서는 다음 포스팅에서 이어가겠습니다.

 

'JavaScript' 카테고리의 다른 글

[JavaScript]로컬저장소 사용하기  (0) 2021.04.27

+ Recent posts