Any Javascript/ECMA-script site or book should give you a good clue as to the basic syntax of the language.
Coming from PHP it shouldn’t be too difficult.
Be sure you understand After effects by itself, because what good is it trying to understand what the Object Model is of the app…
Once you know After Effects, the manual is pretty clear about most objects and methods.
A few excpetions are a.o. “Layer Space transformations” and the Noise-, loop- and Wiggle-functions, they’re completely alien to Javascript.
Dan Ebberts has some great articles and tutorials about those here, and on his site motionscript.com
Anyway,
The problem you’re describing seems like something that could be done with temporalWiggle.
I’m assuming you want the actual positions to remain the same, only the timing of the loop to be altered.
If you apply temporalWiggle to a property like position, the result is based on the keyframed values, but results can go back and forth in time.
Or try precomposing your animation, enable time-remapping on the precomped layer so you can keyframe time.
Set up a loop there (I mean, with keyframes in the time-remapping) and then wiggle or temporalWiggle that time-value.