0

guys pls i need your help it will be big help for me. i am angry and sad in same time i can't understand this section

var param = 'size'; var config = { [param]: 12, ['mobile' + param.charAt(0).toUpperCase() + param.slice(1)]: 4 }; console.log(config.mobileSize); // 4

10th Dec 2020, 10:35 AM
yassin tafouzert
yassin tafouzert - avatar
1 Respuesta
+ 1
The second property is an array of String. 'mobile' + param.charAt(0).toUpperCase() => mobileS mobileS + param.slice(1) -> slice will return all the elements from the position mentioned so it will get everything from 'i' in param. So it becomes => 'mobileS' + 'ize' Which is => mobileSize And config.mobileSize is 4 which is nothing but the 2nd property of config.
10th Dec 2020, 5:08 PM
Avinesh
Avinesh - avatar