{scale: 'f', temperature} is basically the syntax Property value shorthand for {scale: 'f', temperature: temperature} ,
So, in JavaScript with ES6/ES2015 , if you want to define an object whose keys have the same name as the variables passed as properties, you can use the short name and just pass the key name.
Check doc for details
It is important to note that when using this syntax, the JS engine looks in the addition area for a variable with the same name.
If found, this property is assigned the value of a variable.
If it is not found, the value ReferenceError selected. It is worth noting that transpilers will not cause an error during compilation if the variable is not found, but instead declares an object with the name of the variable not found.
However, when the code runs, you still get a ReferenceError , since the variable does not exist.
source share