jimfog Posted May 24, 2011 Share Posted May 24, 2011 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 More sharing options...
justsomeguy Posted May 24, 2011 Share Posted May 24, 2011 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 More sharing options...
ShadowMage Posted May 24, 2011 Share Posted May 24, 2011 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 More sharing options...
jimfog Posted May 24, 2011 Author Share Posted May 24, 2011 You were right, thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.