class

    [코딩애플] 타입스크립트에서의 class : constructor, prototype 타입지정

    타입스크립트에서 class의 constructor 사용하기 일반적인 JavaScript 클래스 및 객체 생성의 예시이다. // JavaScript class Candidate { constructor(personality, age, gender) { this.personality = personality; this.age = age; this.gender = gender; } } const candidate1 = new Candidate('good', 28, 'woman'); JavaScript에서는 타입 정보를 명시적으로 선언하지 않는다. 그렇게 때문에 위처럼만 표기해도 되지만, 타입스크립트에서는 각 속성과 매개변수에 타입지정을 해주어야 한다. // TypeScript class Candidate { ..

    React : 옛날 class문법

    class 문법으로 컴포넌트 만드는 법 class Modal2 extends React.Component { constructor(){ super() } render(){ return ( 컨텐츠.. ) } } class 컴포넌트명 extends React.Component를 만든 후 그 안에 constructor, super, render 세 가지 함수를 넣는다. return 안에 축약할 html을 적는다 class 컴포넌트에서 state 만드는 법 class Modal2 extends React.Component { constructor(){ super(); this.state = { name : 'noran', age : 20 } } render(){ return ( 내 이름은 {this.state...

    [mdn, 드림코딩 외] 객체(Object)와 프로퍼티(property) (2) : 생성/수정과 cloning

    https://sunshineyellow.tistory.com/17?category=1037372 [코딩앙마 외] 객체(Object)와 프로퍼티(property) 객체(Object) key와 value로 이루어질 수 있다. 1. 함수표현식 const goodCoder = function(name, age, coding) { name : 'Noran', age : 20, coding : function(){ console.log('화이팅!'); } } name : 'Noran',.. sunshineyellow.tistory.com https://sunshineyellow.tistory.com/18?category=1037372 [코딩앙마 외] 객체 리터럴과 객체 접근법, 그리고 생성자 함수 객체를 생성하는..

    [mdn, 드림코딩 외] 객체지향 (4) : 클래스의 상속 (sub classing)

    클래스의 상속 (sub classing) class Goodcoder { constructor(age, lang, address) { this.age = age; this.lang = lang; this.address = address; } coding() { console.log(`내가 공부중인 언어는 ${this.lang}입니다.`) } } 이 아래에 새로운 클래스를 만들고 싶은데, class Goodcoder의 값을 상속시키고 싶다면 extends를 넣어 간단하게 처리할 수 있다. class Employee extends Goodcoder {} 이렇게 새 클래스를 만들어 extends로 상속을 하면, 새로운 클래스에 이전 클래스 값들이 상속된다. const noran = new Employee(20..

    [mdn, 드림코딩 외] 객체지향 (2) : 객체(object)와 getter and setter

    객체(object) https://sunshineyellow.tistory.com/17 [코딩앙마 외] 객체(Object)와 프로퍼티(property) 객체(Object) key와 value로 이루어질 수 있다. 1. 함수표현식 const goodCoder = function(name, age, coding) { name : 'Noran', age : 20, coding : function(){ console.log('화이팅!'); } } name : 'Noran',.. sunshineyellow.tistory.com 위 글에서 잠깐 짚고 넘어간 객체를 클래스와 함께 심화학습한다. class Goodcoder { //constructor constructor(name, age) { this.name = ..

    [mdn, 드림코딩 외] 객체지향 (1) : 클래스(class)

    들어가기 앞서 : 생성자함수와 클래스의 차이점 https://sunshineyellow.tistory.com/18?category=1037372 [코딩앙마 외] 객체 리터럴과 객체 접근법, 그리고 생성자 함수 객체를 생성하는 방법에는 두 가지가 있다. 객체 리터럴 생성자 함수 단 하나의 객체만을 생성할 때는 직관적이고 간편한 객체 리터럴을 사용하고, 같은 객체를 대량생산할 때는 생성자함수를 sunshineyellow.tistory.com 위 글에서 객체와 생성자함수를 간단하게 공부했다. 그렇다면 생성자함수와 다른 클래스의 특이점은 무엇일까? 클래스는 new 연산자 없이는 호출이 불가능하다. 클래스는 extends(클래스의 상속)와 super(super클래스의 constructor과 method 호출)를 ..