164. ES8(2017)
.padStart()
padStart get 'Turtle' with 10 spaces in front of it
.padEnd()
padEnd get 'Turtle' with 10 spaces after it
trailing commas(후행쉼표)
const fun = (
a,
b,
c,
d,) => {
console.log(a);
}
fun(1,2,3,4,)
padStart get 'Turtle' with 10 spaces in front of it
padEnd get 'Turtle' with 10 spaces after it
trailing commas(후행쉼표)
const fun = (
a,
b,
c,
d,) => {
console.log(a);
}
fun(1,2,3,4,)
const fun = (
a,
b,
c,
d,) => {
console.log(a);
}
fun(1,2,3,4,)
Everytime you add a new parameter, it's a lot easier.
Object.values
Object.entries
'Object.keys' allowed us to do something similar to arrays but on objects.
Object.keys
let obj = {
username0: 'Santa',
username1: 'Rudolph',
username2: 'Mr.Grinch'
}
Object.keys(obj).forEach((key, index) => {
console.log(key, obj[key]);
})
Object.values
Object.values(obj).forEach(value => {
console.log(value);
})
Object.entries
Object.entries(obj).forEach(value => {
console.log(value);
})
Example.
let obj = {
username0: 'Santa',
username1: 'Rudolph',
username2: 'Mr.Grinch'
}
- We receive this data values from the backend.
- The backend just send us a bunch of users that they had in the database
- We want to generate 'usernames' for that. (We don't want username0, username1, username2)
Object.entries(obj).map(value => {
return value[1] + value[0].replace('username', '');
})
Author And Source
이 문제에 관하여(164. ES8(2017)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@bianjy/164.-ES82017저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)