I have some questions about JavaScript Syntax and looking forward to understand them.
First: I don't understand about this syntax below,
{
Key: () => function()
}
Example in real project:
// Define URL routes
// See https://github.com/flatiron/director
var routes = {
'/': () => render(require('./components/pages/Index')),
'/privacy': () => render(require('./components/pages/Privacy'))
};
it has been used in https://github.com/kriasoft/react-starter-kit/blob/master/src/app.js
What it supposes to do?
Is it the same as { Key: function() {} } ?
Second: About function in JavaScript Object,
{
function() {}
}
Example in real project:
var HomePage = React.createClass({
statics: {
layout: App
},
componentWillMount() {
PageActions.set({title: 'React.js Starter Kit'});
},
render() {
return (.....);
}
});
it has been used in https://github.com/kriasoft/react-starter-kit/blob/master/src/components/pages/Index.js
I would like to appreciate for your answer to explaining why these are valid or if you could send me to the right information on these syntax for JavaScript object?