let Arrow = () => console.log("Arrow");
화살표 함수는 항상 익명함수로 사용한다.
매개변수가 없는 경우 - ( ) 소괄호 필수
let abc = () => console.log("abc");
abc(); // 출력 abc
매개변수가 1개인 경우 - ( ) 소괄호 생략 가능
let abc = a => a+3
console.log(abc(2)) // 출력 5
매개변수가 여러개인 경우
let abc = (a,b) => a*b
console.log(abc(3,5)) // 출력 15
this는 너무 내용이 방대하여 간단하게 알아볼것이다.
우선 일반 함수에서의 this를 살펴보면 일반 함수 내부에서의 this는 전역 객체인 window에 바인딩된다.
이를 사용하여 일반함수를 선언하고 this의 객체틀의 형태는 그대로지만 객체의 값을 쉽게 바꿀수 있다.
function block(hash,height){
this.hash = hash;
this.timestamp =1641519310;
this.height = height;
this.Difficulty = 4;
this.Nonce = 1234123;
}
let a = new block('0000001',1);
let b = new block('0000002',2);
let c = new block('0000003',3);
console.log(a)
console.log(b)
console.log(c)
이외에도 this를 사용할 곳이 많지만 복잡한 내용이 많아 우선 여기까지만 알아봤다.