Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does ‘::’ (double colon) do in javascript for events?

I saw this code and I'm scratching my head trying to decide how it works.

<SCRIPT LANGUAGE=javascript> 

     function SpeechMikeControl::SPMEventButton(lDeviceID, EventId) {
        alert("lDeviceID=" + lDeviceID + ", EventId=" + EventId);
     }

</SCRIPT>

double colon? This is from using a philips speech mike from a web page.

Any idea what this double colon means? It seems like a syntax error to me but it works! (at least in IE).

like image 353
sproketboy Avatar asked Apr 19 '11 10:04

sproketboy


People also ask

What does :: do in JavaScript?

:: is obviously used here to allow either one or two arguments to be passed to the function.

What does double colon mean in programming?

Use the double colon operator (::) to qualify a C++ member function, a top level function, or a variable with global scope with: An overloaded name (same name used with different argument types) An ambiguous name (same name used in different classes)

What are the two colons in R for?

The double-colon operator :: selects definitions from a particular namespace.

What is colon in react?

The colon (:) is a shorthand for v-bind. Meaning, you are binding a property to the component.


4 Answers

I've been able to find an obscure reference in some scanned manual from Microsoft Office Infopath 2003. It appears to be a JScript syntax:

a double colon is used as separator between the script ID and the event name

My guess is that's not part (or no longer part) of Internet explorer's ECMAScript implementation but it belongs (or used to belong) to Microsoft Office's implementation.

like image 75
Álvaro González Avatar answered Oct 03 '22 21:10

Álvaro González


This is an extension to the Javascript language implemented by Microsoft. It's purpose is to specify an event handler for a COM object referenced on the page. SpeechMikeControl is the globally-scoped name of the COM (and/or ActiveX) object:

  • either with an OBJECT or some other element, which has an id property of SpeechMikeControl, or
  • a global variable SpeechMikeControl declared somewhere previously in the Javascript

SPMEventButton is the name of the COM event which will be raised by the SpeechMikeControl object under who-knows-what circumstances.

The double colon is an instruction to connect the function body as a handler to the control's event.

like image 20
richard Avatar answered Oct 03 '22 20:10

richard


Pretty sure it's a syntax error

like image 31
Mild Fuzz Avatar answered Oct 03 '22 20:10

Mild Fuzz


As mentioned in this answer of What does ‘::’ (double colon) do in javascript?

:: is a ES2016 operator that is shorthand for bind. This answer intends to assist those that have encountered :: since the ES2016 spec, however, does not apply to the context in which this question was asked.

like image 45
Dmase05 Avatar answered Oct 03 '22 20:10

Dmase05