분류 전체보기(151)
-
class object 객체지향
class는 붕어빵 틀이라면 object는 붕어빵 속(팥, 크림, 치즈..) 1. Class declaration class Person { // constructor constructor(name, age) { // fields this.name = name; this.age = age; } // methods speak() { console.log(`${this.name}: hello!`); } } const bella = new Person('bella', 20); console.log(bella.name); console.log(bella.age); bella.speak(); 2. Getter and Setter class User { constructor(firstName, lastName, a..
2021.05.17 -
Function 함수
// Function // - fundamental building block in the program // - subprogram can be used multiple times // - performs a task or calculates a value // 1. Function declaration // function name(param1, param2) { body... return; } // one function === one thing // naming: doSomething, command, verb // e.g. createCardAndPoint -> createCard, createPoint // function is object in JS function printHello(){ ..
2021.05.14 -
API 추천사이트
https://github.com/public-apis/public-apis https://public-apis.xyz/page/1
2021.05.14 -
자바스크립트 연산자, if문 for문 switch문
1. String concatenation 문자연결 console.log('my' + ' cat'); console.log('1' + 2); console.log(`string literals: '''' 1 + 2 = ${1 + 2}`); 2. Numeric operators 숫자연산자 console.log(1+1); //add console.log(1-1); //substract console.log(1/1); //divide console.log(1*1); //multiply console.log(5%2); //remainder console.log(2**3); //exponentiation 3. Increment and decrement operators +,- let counter = 2; con..
2021.05.13 -
변수 var, let, const
이전에는 var를 사용했었지만 현재는 let만 사용한다 console.log(age); age = 4; var age; //var는 변수를 정의하기 전에 출력을 하면 오류가 나야 정상인데 undefined로 값이 나옴 항상 변수를 먼저 선언해줘야 함 let globalName = 'global name'; { let name = 'bella'; consol.log(name); //bella 로컬변수 //로컬 변수는 함수 안에 선언된 변수로 같은 함수 안에서만 출력가능하다. 함수 바깥에서는 출력불가능 } consol.log(globalName); //global name 글로벌 변수 //글로벌 변수는 함수 밖에 선언된 변수로 어디서든 출력가능하다 const (constants) - 자바스크립트에서는 가능하..
2021.05.12 -
JavaScript를 html에 연결하는 효율적인 방법
1. 에 넣기 -> script 파일이 클 경우 화면로딩시간이 길어질 수 있다 2. 에 넣기 -> 화면로딩 이후 script다운로드가 시작되기 때문에 script를 이용한 동적인 사이트일 경우 원하는 효과를 바로 보여줄 수 없다 3. head+asyn -> html다운과 script다운이 병렬형식으로 진행되지만 script다운이 끝나면 바로 실행이 된다 자바스크립트 다운받는 시간은 줄일 수 있지만 html이 다운받아지기 전에 script가 실행되는 경우 원하는 이벤트 조작이 불가능할 수 있고, script가 실행되면 html 다운로드 진행은 멈춰질 수 있어 화면 로딩 시간이 길어질 수 있다 4. head + defer (가장 좋은 방법) -> 병렬형식으로 다운로드 받고, script는 html을 모두 다..
2021.05.12