Jump to content

{properties} = object syntax


Mnus
 Share

Recommended Posts

Cu.import("resource://gre/modules/NewTabUtils.jsm");

var {
  links: gLinks,
  allPages: gAllPages,
  linkChecker: gLinkChecker,
  pinnedLinks: gPinnedLinks,
  blockedLinks: gBlockedLinks,
  gridPrefs: gGridPrefs
} = NewTabUtils;

and the scipt of NewTabUtils.jsm is

/**
 * Singleton that provides the public API of this JSM.
 */
this.NewTabUtils = {
 a_Property_is_here: false,
 Some_Method_A: function Some_Method_A() {
}
 Some_Method_B: function Some_Method_A() {
}
 And_so_on: function And_so_on() {
}
  links: Links,
  allPages: AllPages,
  linkChecker: LinkChecker,
  pinnedLinks: PinnedLinks,
  blockedLinks: BlockedLinks,
  gridPrefs: GridPrefs,
  placesProvider: PlacesProvider,
  activityStreamLinks: ActivityStreamLinks,
  activityStreamProvider: ActivityStreamProvider
};

What does the part "var{properties}=NewTabUtils;"  mean? I understand if that's "NewTabUtils={properties};"

And another minor question is about the second script, in the Class-like JS methods, properties are asigned at bottom of the script, also bottom of the file. I guess that's because it is easy to read, but not sure the reason.

Would somebody know these questions?

thanks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...