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
2 Respuestas
+ 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
+ 1
maf thank you