문자열 표기법
` ` 식으로 표현하여 문자열에 변수를 추가
const val1 = 'my String1'; const val2 = 'my String2'; const litVal = `${val1}, ${val2}`;
JavaScript
비구조화
객체 비구조화
객체를 풀어서 바로 변수로 선언
: 을 활용하여 변수명 변경 가능
const address = { country : 'South Korea', city : 'Seoul', street : 'Gangnam', str_num : 141, postcode :'0015' } const {country,city} = address; console.log(`${country}, ${city}`); //rename const {country:a,city:b} = address; console.log(`${a}, ${b}`);
JavaScript
배열 비구조화
배열의 순서대로 변수 선언
const [firstCountry,secondCountry] = ['Japan','SouthKorea', 'America']; console.log(firstCountry,secondCountry); const [thirdCountry] = ['Japan','South Korea', 'America']; console.log(thirdCountry);
JavaScript
객체 리터럴
객체안에서의 키와 벨류가 동일하다면 다음과 같이 사용해도 된다. (배열과 유사한 모습으로 선언)
//객체 리터럴, Object Literal function getAddress(country, city, street){ const myAddress = {country, city, street}; console.log(myAddress); } function getAddressOrigin(country, city, street){ const myAddress = { country:country, city:city, street:street }; console.log(myAddress); } getAddress('Japan','South Korea', 'America'); getAddressOrigin('Japan','South Korea', 'America');
JavaScript

'Web 개발 > JS ' 카테고리의 다른 글

ES6 : async & await  (0) 2019.06.08
ES6 : Spread, Rest Operator  (0) 2019.06.08
ES6 : Arrow Function, Default Params  (0) 2019.06.08
ES6 : import & export, Classes  (0) 2019.06.08
ES6 : Map & Set  (0) 2019.06.08

+ Recent posts

"여기"를 클릭하면 광고 제거.