How to access objects variables from javascript

I know how to access scene variables like this
but don’t know how to access objects variable

Pass the object to the “objects” list, select an object, for example:

var obj = objects[0];

Finally you can access object variable as you do with the scene:

var myNumber = obj.getVariables().get("MyVar").getAsNumber();