js 중 ES6 의 계승

4681 단어 자바 script

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
	</body>
</html>
<script>
	class Person{
		constructor(newId,newName) {
		    this.id = newId;
			this.name = newName;
		}
		eat(){
			console.log("eat()");
		}
	}
	//class     extends    
	class Student extends Person{
		constructor(newId,newName,newScore){
			//super            
			super(newId,newName);
			this.score = newScore;
		}
	}
	
	let s = new Student(1,"  ",99);
	
	console.log(s.id);
	s.eat();
</script>

좋은 웹페이지 즐겨찾기