I know you can use the : when
Opening my console in a Chrome browser I can execute:
window.open('http://google.ie')
That works fine. Then I type the same but using a colon instead:
window:open('http://google.ie')
Why does using a : still work and execute the open function?
The : makes window into a label rather than a variable:
window:
open('...');
continue window;
And, since window is the global object in browsers, open() is a global function and can be directly referenced with or without it.
// both work
window.open('...');
open('...');
But, it's not a complete replacement for all objects and their properties:
var o = { foo: 'bar' };
o:foo // ReferenceError: foo is not defined
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