Platform specific code

Hey guys!
I’m currently porting a simple 2D game from Unity to cocos-2dx using JS bingding

I wonder how can I run platform specific code.
For instance, let’s say I’d like to use game center os iOS

if(cc.sys.os == cc.sys.OS_IOS)
{
// load game center info
}

Or if I’m targeting web and I want to use facebook

if(cc.sys.os == cc.sys.DESKTOP_BROWSER)
{
// load facebook SDK js
}

Is there any other way to do that? Maybe an elegant way?

Cheers!

For c++ I don’t know if there is better solution, but in one place of my project I use this code and it works as I want.

if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
{
// stuff
}

I guess for js its same thing

http://www.cocos2d-x.org/reference/native-cpp/V3.6/d0/de1/group__core.html#ga5be836f305c9cd8b44ffb7c964f4cbd9