
한마디
1. 정규식의 많은 변화
1.1 /s 플레그 추가
- 기존 .(dot) 은 하나의 문자를 검색을 의미하지만, 줄바꿈 문자의 경우 false 를 반환하는 문제가 있었음.
- 그래서 새로 추가된 /s 플레그를 통해 해당 값을 확인할 수 있음
// [예시 1]
/hello.bye/.test('hello\nbye') // prints false
// [예시 2]
/hello.bye/s.test('hello\nbye') // prints true
1.2 RegExp 를 통한 그룹 캡춰
- groups 이하 지정한 이름(year, month, day)을 통해 접근 가능
// [예시 1] 예전 방식
const REGEX = /([0-9]{4})-([0-9]{2})-([0-9]{2});
const results = REGEX.exec('2018-07-12');
console.log(results[1]); // prints 2018
console.log(results[2]); // prints 07
console.log(results[3]); // prints 12
// [예시 2] 새로운 방식
const REGEX = /(?<year>[0-9]{4})-(?<month>[0-9]{2})-(?<day>[0-9]{2});
const results = REGEX.exec('2018-07-12');
console.log(results.groups.year); // prints 2018
console.log(results.groups.month); // prints 07
console.log(results.groups.day); // prints 12
1.3 Assertions
- 긍정(positive ?<=...) : 매칭하는 경우
'$foo #foo @foo'.replace(/(?<=#)foo/g, 'XXX')
// prints $foo #XXX @foo
- 부정(negative ?<!...) : 매칭되지 않는 경우
'$foo #foo @foo'.replace(/(?<!#)foo/g, 'XXX')
// prints $XXX #foo @XXX
1.4 유니코드 탐색
- 유니코드 지정한 유니코드로
\p{} 탐색이 가능해 짐.
/\p{Script=Greek}/u.test('μ') // prints true
2. 나머지(rest)/펼치기(spread) 속성
- ... 이전에 매칭된 값과 아닌값을 자동으로 채워 넣어준다.
const values = {a: 1, b: 2, c: 3, d: 4};
const {a, ...n} = values;
console.log(a); // prints 1
console.log(n); // prints {b: 2, c: 3, d: 4}
3. Promise에 finally 추가됨
- Promise.prototype.finally
- 성공 여부에 관계없이 반드시 수행되는 항목
fetch('http://website.com/files')
.then(data => data.json())
.catch(err => console.error(err))
.finally(() => console.log('processed!'))
4. 비동기 반복
- 이제 반복문에도 await 이 사용가능해짐 !!
for await (const line of readLines(filePath)) {
console.log(line);
}
굿굿굿!!! 감사합니다!!!
자꾸 일부러라도 조금씩 새로운 기능들을 써보려고 하고 있는데~~ 도움이 되겠네요!!! 매우!! ㅋ
신기능이 좋지요 ㅋ 어짜피 ie버린 시점에 크롬은 자동 업뎃 모드인지라 ㅎㅎ
es9 가즈아
정규식 조으다는ㅋㅋ
규식이 형이 최고죠 !
제가 요즘 "html5, css3, js"에 관심이 있는데
좋은글 잘 읽었습니다
감사해요~
네--
오~ 굿굿굿 정보 감사요!
굿굿굿 개발 가즈아~~
await 가 등장하면서 반복문을 쓸 수 있다는 점이 큰 강점이었는데,
for await 를 쓰면 코드가 좀 더 깔끔해 지는군요.
for await 를 통해 좀 도 깔끔해진 코드를 작성할 수 있을거 같아요
위 예시처럼 비동기 라인 리딩 갘은 경우도여 ㅋ
그런데 실제 Promise.all 을 더 선호해서 사용할거 같아요
비순차 적이긴 하지만 효율이 좋은지라 ㅜㅜ