0

i do not get a small section from module ES6 objects, help me to understand this code

here is the link, it is from course only https://code.sololearn.com/Wn2yM60jYTfM/#js

10th Nov 2020, 2:59 PM
dishannt jain
dishannt jain - avatar
2 ответов
+ 4
let name = "fullname" let obj = { name: "John" } Which key would the obj contain? "name" or "fullname"? coz name = "fullname", right? But it would contain exactly what you wrote there, "name". But what if you wanna use the name variable instead of literal string "name"? You would have to put it in square brackets. let obj = { [ name ] : "John" } // { fullname: "John" } In the next example, he joined together some strings param.charAt(0).toUpperCase()'s explanation param = "size" "size".chatAt(0) is "s" and after toUpperCase(), its "S". param.slice(1) means the string "size" after slicing it from first index, so the remaining is "ize" [ "mobile" + "S" + "ize" ] : 4 thats why config.mobileSize = 4
10th Nov 2020, 3:16 PM
maf
maf - avatar
+ 1
maf thank you
12th Nov 2020, 5:53 AM
dishannt jain
dishannt jain - avatar