How to make a platform dependent code?

I couldn’t find any similar to the #ifdef that we have in c++ as for example:
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)

I would like to know in which system my html5 with JSB code is running, there is any glue into the code to verify that?

I know that cc.Browser has an platform attribute, but as expected there’s no glue for cc.Browser (what also creates a problem if you are trying to create a code that run different from a Canvas to a WebGL ecosystem).

Anyway, anyone has made anything related to that?

(BTW I did “cc.renderContextType != cc.CANVAS” to a canvas/webgl lookup, it doesn’t break the JSB)

Hi, you could find the solution in the namespace of sys

if ( sys.platform !== 'browser')

And you could check whether the current platform support opengl by

if( 'opengl' in sys.capabilities )

Perfect! Thank you again “guru” James ;)!

There is anyway inside that to verify if it is on Android or other platform?