dom1n1k
dom1n1k

Reputation: 31

Bing Maps v8 and strange work of instanceof

Load map:

map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
    ...
});

And it works fine (visually). But:

console.log(map instanceof Microsoft.Maps.Map);  // false

Whaaat?! :) How can I check it? Is it a bug or my mistake?

You can try example in Bing Dev Center sandbox:

http://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk#loadMapAsync+JS

Thanks

Upvotes: 0

Views: 132

Answers (1)

traktor
traktor

Reputation: 19366

Using the Bing Apps dev page, if you edit out the new it still works, and logging map.constructor just prints function n(). So it appears Microsoft has not been entirely accurate as to what the code does at the moment - which is to act as an object factory.

Microsoft may be reserving the right to make Maps.Map an object constructor in the future. At the moment instanceof returning false is correct.

Upvotes: 0

Related Questions