ES5는 뭐고 ES6는 뭘까?
우선 ES는 ecmascript의 약자로 자바스크립트의 표준, 규격이라고 볼 수 있다.
뒤에 붙어있는 숫자는 버전을 뜻하는데 ES5는 2005년 출시, ES6는 2016년 출시로 사이에 많은 기간차이가 있다. ES6이후에는 매년 업데이트가 되고있는 반면 5,6는 기간차이만큼 달라진 점이 많다.
문법적으로 달라진 걸 살펴보자 !
//ES5
var height = function(height){
var heigth = height || 180
}
//ES6
const height = function(height = 180){
}
//ES5
var first_name = "zoey"
var last_name = "An"
var me = "제 이름은" +last_name+ +first_name+ "입니다."
//ES6
const me = `제 이름은 ${last_name} ${first_name} 입니다.`
여러 줄이 되었을 경우 \n + 으로 줄띄움을 해줬어야 했으나 백틱``을 사용하면 문제없습니다!
//ES5
var Lorem = "Lorem Ipsum is simply dummy text of the\n+ printing and typesetting industry. Lorem Ipsum has been \n + the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and\n + scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into\n + electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the \n +release of Letraset sheets containing Lorem Ipsum \n +passages, and more recently with desktop publishing \n +software like Aldus PageMaker including versions of Lorem Ipsum."
//ES6
const Lorem = `Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.`
<script type="module" src="./app.mjs"></script>
더 많은 것들은
출처 : https://hbsowo58.tistory.com/407
여기 블로그를 참조하자!