且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在javascript中,什么是构造函数?什么不是?

更新时间:2023-10-29 23:26:58

任何本机函数都可以作为构造函数调用(即使它不是设计的)。任何不可赎回的东西lso不能是构造函数。例如 new 3 给出相同的错误。

Any native function may be called as a constructor (even if it wasn't designed to be). Anything that's not callable also cannot be a constructor. eg new 3 gives the same error.

在您的页面中, google.maps。 Geocoder 只是 undefined ,这当然无济于事。查看Google的地图脚本,无法加载Geocoder模块,因为它正在使用 document.write 这样做,一个必须从HTML中包含的< script> 运行的方法解析时的文档,不是像你在这里那样使用DOM脚本导入的。

In your page, google.maps.Geocoder is simply undefined, which certainly isn't going to help. Looking at Google's maps script it's failing to load the Geocoder module because it's using document.write to do so, a method that has to be run from a <script> included in the HTML document at parse time, not imported by use of DOM scripting as you're doing here.

当然不希望从通过客户端加载的页面运行 - 方XSLT。这将给你很多浏览器问题和零搜索引擎优化的存在。这种疯狂的目的是什么?

It certainly doesn't expect to be run from a page loaded via client-side XSLT. This is going to give you lots of browser problems and zero SEO presence. What is the purpose of this craziness?