Jump to content

+ operator explanation


jimfog

Recommended Posts

I am trying to make a firefox extension using the mozilla APIs.Here is a a piece of code that i can understand where the + operator is useful to exactly:

var item = contextMenu.Item({ label: "xxxxxxxxx", context: contextMenu.SelectionContext(), contentScript: 'on("click", function () {'+'alert("Item clicked!");'+'});'});
I am trying to make a context menu appear upon selection of a text from a webpage.I do understand the code in general, but i cannot understand what the + operator is doing there.From what i know + is used to add numbers and to join strings.So what is doing there? Explanations(as always) are welcome.Thanks.
Link to comment
Share on other sites

In that particular example, there's no reason for it to be there. Might as well just do this:contentScript: 'on("click", function () {alert("Item clicked!");});'You might see people using that if the string goes across several lines:

contentScript: 'on("click", function () {' +				'alert("Item clicked!");' +				'});'

Link to comment
Share on other sites

From what i know + is used to add numbers and to join strings.
And that's exactly what it's doing:contentScript: 'on("click", function () {' + 'alert("Item clicked!");' + '});'EDIT:...But like JSG said, in this case it really serves no purpose.
Link to comment
Share on other sites

You were right, thanks.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...