I need to check if an object passed to a function as an argument of type any is an image. Basically, I need to pass the argument to different function depending on the type. I use the typeof keyword for all the basic JS types like number and string etc. and I have a separate check in case this returns ‘object’.
When an object is detected, the Array namespace has an isArray function I can use to recognise the type as array and pass it on, however I have found no way to differentiate any other object subtypes. I’m forced to pass the argument on to a generic functions for objects which does not work for my purpose (in this case checking equality).
Afaik the image namespace does not have such a function for checking types, isinstance cannot be used as ‘Image’ is treated as a type, not a class, and I think checking properties or the constructor to deduce type is not possible in MakeCode. Does anyone know some kind of alternate method or workaround for this? @richard? Thanks
Sure, I’ll get to it. I think it would be a nice feature to have alongside the Array one, although its use case is pretty niche like right now. Thanks everyone for your help!