Data Scientist 옌

매일 발전하는 IT문제해결사

국비지원교육 (22.01-22.07)/강의노트

22-06-16(목) 096일차 [JavaScript] 자바스크립트 상속

옌炎 2022. 6. 24. 14:08
728x90

수업내용


1교시 (09:30-10:20)

  • script_18.html
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Classes</title>
	<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
</head>
<body>
	<h1>Classes</h1>
	<p>Open the console</p>
	<script type="text/babel">

		// 이전 방식으로 생성자를 만들고 프로토타입 설정하기

		function Vacation(destination, length) {
	    	this.destination = destination
	    	this.length = length
	    }

	    Vacation.prototype.print = function() {
	    	console.log(this.destination + "은(는) " + this.length + "일 걸립니다.")
	    }

	    var maui = new Vacation("마우이", 7)

	    maui.print()

		// 클래스를 사용해 정의하는 새로운 방식

	    class Vacation_1 {

	    	constructor(destination_1, length_1) {
	        	this.destination_1 = destination_1
	        	this.length_1 = length_1
	      	}

	      	print_1() {
	        	console.log(this.destination_1 + "은(는) " + this.length_1 + "일 걸립니다.")
	      	}

	    }

	    const trip_1 = new Vacation_1("칠레 산티아고", 9)

	    trip_1.print_1()


	    // 상속

	    class Vacation_2 {
	     
	    	constructor(destination_2, length_2) {
	        	this.destination_2 = destination_2
	        	this.length_2 = length_2
		      }

		      print_2() {
	    	    console.log(this.destination_2 + "은(는) " + this.length_2 + "일 걸립니다.")
	      	}

	    }

	    class Expedition extends Vacation_2 {
	      
	     	constructor(destination_2, length_2, gear) {
	        	super(destination_2, length_2)
	        	this.gear = gear
	      	}

	      	print_2() {
	        	super.print_2()
	        	console.log(`당신의 ${this.gear.join("와(과) 당신의 ")}를(을) 가져오십시오.`)
	      	}
	    }

	    const trip_2 = new Expedition(
	     	
	     	"한라산",
	      	3,
	      	["선글라스", "오색 깃발", "카메라"]
	    )

	    trip_2.print_2()

	</script>
</body>
</html>

2교시 (10:30-11:20)

  • react 에서 사용할 ES6 자바스크립트 문법
    • 월요일 5시까지 강의노트 내용 정리해서 올리기

      1. const

      2. let 

      3. template string 

      4. module 
      ES6
      export
      export default

      import xxx from './화일이름'

      CommonJS 
      exports
      module.exports

      require('화일이름');

      5. arrow function
      (파라미터1, 파라미터2.. n) => {}

      호이스팅 : hoisting : 표현식 함수는 호이스팅 안됨

      6. spread operator
      ...변수명
      first, finish
      ...rest

      7. Asynchronous 
      fetch() ~ then() 
      async / await
      async () =>  await 함수()
      new Promise() 
      pending
      fulfilled
      rejected
      settled

3교시 (11:30-12:20)

  • 스프링 코드 버전업하기

4교시 (12:30-13:20)

  • 스프링 코드 버전업하기

5교시 (14:30-15:20)

  • 스프링 코드 버전업하기

6교시 (15:30-16:20)

  • 스프링 코드 버전업하기

7교시 (16:30-17:20)

  • 스프링 코드 버전업하기

8교시 (17:30-18:30)

  • 스프링 코드 버전업하기

Notes


728x90