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).
:: is obviously used here to allow either one or two arguments to be passed to the function.
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)
The double-colon operator :: selects definitions from a particular namespace.
The colon (:) is a shorthand for v-bind. Meaning, you are binding a property to the component.
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.
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:
OBJECT
or some other element, which has an id
property of SpeechMikeControl
, orSpeechMikeControl
declared somewhere previously in the JavascriptSPMEventButton
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.
Pretty sure it's a syntax error
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With