3 ms·
This happens because of scope chaining in JavaScript. If you call a function it will look for it in the current context. If it’s not there it will try to find i
by camjohnson26 7y ago
This happens because of scope chaining in JavaScript. If you call a function it will look for it in the current context. If it’s not there it will try to find it in the parent. If it’s not there it will keep checking the parent objects until it finds it, or throw an exception. Since window is the top level context and includes a print function, it gets called and shows the printer dialog.
- minitech 7y agoNot the parent objects – the containing scopes. (Which is how scope works in most languages.)