This demo code is from react docs , you could search this sentence on the page:
this.setState({scale: 'c', temperature});
This demo code is from react docs , you could search this sentence on the page:
this.setState({scale: 'c', temperature});
With syntactic sugar on top of ES6 syntax, this.setState({scale: 'c', temperature});
is treated as
this.setState({scale: 'c', temperature: temperature});
and hence it works as desired. This is an object property value shorthand syntax. You can read more about it here