ARC-540 에서 알게된 내용들 var args = [].slice.call(arguments);

Steve·2022년 9월 8일
0

많다. 정확히 모르고 있는 용어들이

apply
call
slice

제로초님 블로그 설명
https://www.zerocho.com/category/JavaScript/post/57433645a48729787807c3fd

[].slice.call(arguments);

객체인 arguments를 배열로 만들기 위한 구문 이랜다

  1. [].slice까지는 함수를 반환.모든 함수는 call 메서드를 갖고 있다.
  2. call 메서드는 context 를 변환해서 함수(slice)를 호출해주는 것이라고 생각하면 된다

context 변환이 뭔데?

참고로 string도 유사배열이다. length property를 가지며, 0부터 index로 접근할 수 있기 때문이다.
유사배열이란, 배열은 아니지만 length property를 가지며, 0부터 시작하는 property가 있어서 index로 접근할 수 있는 자료구조를 의미한다.

...new Set([~~~])

중복내용들을 제거후 배열로 변환
et 을 사용해 중복 제거 후 배열 형태로 변환해줘야 정상적으로 데이터를 확인할 수 있습니다

Promise.resolve

Promise.prototype.then()

Object.keys

Object.keys() 메소드는 주어진 객체의 속성 이름들을 일반적인 반복문과 동일한 순서로 순회되는 열거할 수 있는 배열로 반환합니다.

const object1 = {
a: 'somestring',
b: 42,
c: false
};
console.log(Object.keys(object1)); // ["a", "b", "c"]

Array.from

Array.from 은 유사 배열을 배열로 만들어주는 메소드이고, 두번째 인자로 각각의 유사배열에 전달할 함수를 넘길 수 있다.

// 1. 문자열을 배열로 만드는 예시
console.log(Array.from("Hello"));
// [ 'H', 'e', 'l', 'l', 'o' ]

// 2. 유사 배열 객체를 배열로 만드는 예시
console.log(Array.from({ 0: "강", 1: "성", 2: "구", length: 3 }));
// [ '강', '성', '구' ]

// 3. 함수의 매개변수들을 순서대로 배열로 만드는 예시
const funcA = (...arguments) => {
    return Array.from(arguments)
}

console.log(funcA(1,2,3,4,5));
// [ 1, 2, 3, 4, 5 ]

아얼ㅇ랴얼떻게 가져오고 있는거지ㅣㅣㅣㅣㅣ

Set 객체

=> 중복된 값이 있으면 한개만 유일하게 남겨줌(중복허용X)
참고

let arr = new Array(1,2,3,4,5);
const set = new Set(arr); // set {...} 객체로 생성
const newArr = [...set] // 전개연산자로 Set객체를 다시 배열로 변환
//
console.log(newArr); //[1, 2, 3, 4, 5]
let arr = new Array(1,2,3,4,5);
const set = new Set(arr);
const newArr = Array.from(set);
//
console.log(newArr); //[1, 2, 3, 4, 5]

https://intrepidgeeks.com/tutorial/new-set

차장님 혹시 오늘 오후 시간에 회사코드 몇가지에 대해 여쭙고자 하는데 면담좀 가능할까요?
전반적인 연루 돼있는 파일들은 파악을 해서 모양은 만들어 놨는데 데이터 가져오는게 감이 안잡혀서요..!
헤드라인을 고대로 따라하며 되겠다라고 하셔서 그것만 엄청 보다가 헤드라인은 항상 보이게 처리를해서 show가 없는 상태입니다. 고로 show가 있는 overline 컴포넌트를 착안해서 작업을 진행하던 중입니다.

axois.create

const axios = require('axios');
const instance = axios.create({ timeout: 1000 });

// `instance` is an instance of the same class as `axios`, so it has
// the same methods
axios.constructor === instance.constructor; // true

// For example, `instance.get()` lets you send a GET request, but
// it will also have the 1000ms timeout.
await instance.get('https://httpbin.org/get?hello=world');

Expected newline before "}"
그래 새로운 줄 만들었짜나! 근데도 자꾸 에러뜸 이떄는 어케함?
-> whitespace 있나 체킹ㄱㄱ

profile
Front-Dev

0개의 댓글