0

I would like to ask what does mean this:

document:HideContent('content1');

I can't find any explanation why function HideContent defined as regular function is called with colon (":") instead of dot "." as usual. Does this have any special meaning? Or dos it have some features?

4
  • Can you add complete relevant code. Commented Nov 6, 2015 at 9:17
  • Where did you come across this particular piece of code?! Commented Nov 6, 2015 at 9:20
  • @Tushar: code function HideContent(content) { // ... do something with content } document:HideContent('content1'); code Commented Nov 6, 2015 at 9:21
  • @deceze here: ascendedarcade.com/content/… Commented Nov 6, 2015 at 9:24

1 Answer 1

2

That syntax can only possibly be a label. It's creating the label document and then executes one statement within it (HideContent()). Since the label isn't used within any loop construct by the author, it's pointless.

I suspect the author of the code doesn't really know Javascript and wanted to do something like call HideContent in the "global scope", but found document.HideContent to not work and pounded on the code until it stopped throwing errors. That the result is rather nonsensical and doesn't actually do what they thought it does didn't occur to them. This will work exactly the same when you simply omit document:.

(BTW, the "global scope" resolution would correctly be window.HideContent().)

Sign up to request clarification or add additional context in comments.

6 Comments

"This will work exactly the same when you simply omit document:.". No, maybe the label is used by the other scripts.
Well, look at the origin page the OP links to in the comments above. It makes absolutely no sense there.
@Tom As a rule of thumb, 90% of Javascript snippets you find on random blogs are hideous. The darker and more "hackery" the blog theme, the worse it is. (Only half joking.) ;)
"That syntax can only possibly be a label." - Or an object literal. Still unnecessary of course.
@Zsolt This would be invalid as an object literal, even as a partial one; the trailing ; is not allowed within an {} object literal.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.