Reputation: 850
say i have an array x and a constructor
function Road(footpath,divider,length,lanes){}
and
x[1] = new Road(1,1,1,1);
now how do i determine that x[1] is an object of type Road?
Upvotes: 0
Views: 36
Reputation: 16519
Simple like this
if(x[1] instanceof Road) {
//Hey, you have a road!
}
Upvotes: 4