Sandeep Kumar Sandeep Kumar - 6 months ago 46
Javascript Question

I don't understand what's going on this syntax javascript

How gonna assign in

const { Types, Creators }
in the below code I mean what Types gonna hold and what Creators gonna hold.

const { Types, Creators } = createActions({
userRequest: ['username'],
userSuccess: ['avatar'],
userFailure: null

var createActions = (function (config, options) {
if (R.isNil(config)) {
throw new Error('an object is required to setup types and creators');
if (R.isEmpty(config)) {
throw new Error('empty objects are not supported');

return {
Types: convertToTypes(config, options),
Creators: convertToCreators(config, options)

Answer Source

The syntax is object destructuring assignment. Types and Creators will be defined as the Types and Creators properties returned from the object returned at createActions() call. For example

const {Types, Creators} = (() => {
  return {Types:0, Creators:1}

console.log(Types, Creators)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download