반응형
개체를 이미 정의 된 변수로 분해하는 방법은 무엇입니까?
다음은 구문 오류를 생성합니다.
let source,
screenings,
size;
source = {
screenings: 'a',
size: 'b'
};
{
screenings,
size
} = source;
예상 결과:
screenings should be equal to 'a'
size should be equal to 'b'
({
screenings,
size
} = source);
링크 된 문서에서 :
선언없이 객체 리터럴 비 구조화 할당을 사용할 때 할당 문 주위의 (..) 구문이 필요합니다.
그리고 분명히 let
변수를 재 선언 할 수 없기 때문에 이것을 사용해야 합니다. 을 사용하는 경우 var
다시 선언 할 수 있습니다.var { screenings, size } = source;
반응형
'programing' 카테고리의 다른 글
64 비트 컴퓨터에서 sizeof (int)는 얼마입니까? (0) | 2020.11.20 |
---|---|
탭 모음 컨트롤러에 새 탭 추가 (0) | 2020.11.20 |
Ansible : 명령 줄에서 역할을 실행할 수 있습니까? (0) | 2020.11.20 |
HTML 텍스트 상자에서 텍스트를 어떻게 오른쪽 정렬합니까? (0) | 2020.11.20 |
'필드를 찾을 수없는 유형의 빈이 필요합니다.' (0) | 2020.11.19 |