전체 글 (37) 썸네일형 리스트형 JS 클래스 [패스트캠퍼스 챌린지 04일차] 생성자 함수 const myName = { firstName:'Kaki', lastName:'Tree', getFullName: function () { return `${this.firstName} ${this.lastName}` } } console.log(myName) // {firstName: 'Kaki', lastName: 'Tree', getFullName: ƒ} console.log(myName.getFullName()) // Kaki Tree JS의 클래스 프로그래밍 언어에서 말하는 클래스와는 좀 차이가 있지만, 일단 그건 패스 프로토타입 prototype 메모리 효율적으로 관리 new 키워드... 생성자 함수 생성자 함수는 일반 함.. 함수 [패스트캠퍼스 챌린지 03일차] 기명 함수 : function 함수이름 () {} 이름이 있는 함수 ```jsx function a() { console.log(1234) } //함수 호출 a() // 1234 ```익명 함수 : function () {} 이름이 없는 함수 ```jsx let b = function () { console.log(1234) } //함수 호출 b() // 1234 ``` 함수 호출 : 함수이름() or 변수이름() 선언된 함수 이름으로 호출할 수 있다 방식은 → 함수이름() 괄호 안에는 인수를 삽입하여 호출 가능 함수를 변수에 왜 담아? - 빌드업 고고 ```jsx function sum(x, y) { console.log(x + y) } /*함수 호출*/ sum(1, 3) // 4 /*재활용 가능*/ .. 조건문, 반복문 [패스트캠퍼스 챌린지 02일차] 조건문 getRandom 루트 경로에 getRandom.js 파일 생성 export default function random() { return Math.floor(Math.random()*10) } main.js 상단에 import 코드 작성 import random from './getRandom' 새로고침 할 때마다 새로운 값이 나옴 console.log(random()) If statement 맞는 조건을 찾아 아래로 착착 내려감 if, else const a = random() if (a === 0) { console.log('a is zero') } else { console.log('rest...') } if, else if, else const .. 이전 1 ··· 9 10 11 12 13 다음