async = 다운로드 병렬, 실행 순서가 보장되지 않음
defer = 다운로드 병렬, 실행 순서 보장
하지만 현재에는 인터넷 속도가 빨라져 두 가지 다 같은 결과를 보여줄 확률이 큼
const a = "1";
const b = 1;
a == b // true;
const a = "1";
const b = 1;
a === b // false;
const speak = function sum(){
console.log("함수 표현식 입니다");
sum(); // 재귀적 호출
}
speak(); // 함수 호출
const speak = function(){
console.log("함수 표현식 입니다");
}
speak(); // 함수 호출
function speak() {
console.log("함수 선언식 입니다");
}
speak(); //함수 호출
function speak = () => {
console.log("화살표 함수 입니다");
}
speak(); //함수 호출
function Shape(width, height) {
this.width = width;
this.height = height;
}
Shape.prototype.getArea = function () {
console.log("i'm shape");
return this.width * this.height;
};
const rect1 = new Shape(10, 20);
console.log(rect1.__proto__);
console.log(rect1.__proto__.getArea()); // NAN
console.log(rect1.getArea()); // 200 10 * 20
__proto__생략해도 getArea()는 접근 가능
prototype는 생략하게 되면 Shape 객체 자체에 추가되기 때문에 생략하지 않아야 함
// 클래스 문법
// 클래스는 class 키워드를 사용해서 선언
// 클래스는 내부에 constructor메소드를 가지고 있음
class order{
constructor(color){
this.color = color;
}
getColor(){
return this.color;
}
}
const shape1 = new Shape("blue");
console.dir(shape1);
console.log(shape1.getColor());
// 상속
// extends키워드로 상속을 진행
class Rectangle extends Shape{
}