Reputation: 7162
I've came across the following code block inside a Node.js / React app yet I am not sure what does the three dots ( ... ) refer to? I tried searching the web but couldn't find any information, so will appreciate any help on clarifying what they are exactly? Thanks
import item from './item';
import user from './user';
import warehouses from './warehouses';
module.exports = {
...item,
...user,
...warehouses,
};
Upvotes: 0
Views: 516
Reputation: 341
The three dots is called the "spread operator". It performs the same function as Object.assign()
. It lets you copy the properties from one object to another object.
For example:
const a = {a: 1};
const b = {b: 2};
const c = {...a, ...b}; // c === {a: 1, b: 2}
For more reference: http://redux.js.org/docs/recipes/UsingObjectSpreadOperator.html
Upvotes: 5