It’s logical to finish with the b2gearJoint since it connects two joints together. All the joint types we looked at provide really cool functionality but what’s even cooler is using them together to create a complex mechanic.
The b2GearJoint connects either two b2RevoluteJoint together or a b2RevoluteJoint and a b2PrismaticeJoint. Once connected the two joints influence each other. The two joints must reference the same static b2Body in order to work properly. The value generated by the first b2Body is reflected by the second b2Body. You have also a ratio value that will multiply the value generated by the first b2Body. In the following example, the wheel on the left has a motor that you can control with the two green arrows. The wheel on the right (b2RevoluteJoint) and the platform (b2PrismaticJoint) have no motor but they are all linked together using a b2GearJoint. When the first wheel turns it makes the second wheel turn and this second wheel makes the platform move:

Relevant code:

geardef = new b2GearJointDef();

geardef.bodyA = secondweel;

geardef.bodyB = firstweel;

geardef.joint1 = revolutejoint as b2Joint;

geardef.joint2 = revolutejointtwo as b2Joint;

geardef.ratio = -1;

world.CreateJoint(geardef as b2JointDef);

Linking the second wheel and the first together. First b2Body is the wheel on the right, second b2Body is the wheel on the left (with the motor). We then pass the b2RevoluteJoint, the first one being attached to the first b2Body and second one to the second b2Body. Here we inverse the generated value with a ratio of -1.