When you want to create and link complex animations, but want to avoid creating tens or hundreds of keyframes by hand, try using expressions. An expression is small piece of JavaScript code that you can plug into animated properties in your After Effects projects, that evaluate to a single value for a single layer property at a specific point in time.
Unlike a script, which tells the application to do something, an expression tells a property to do something.. For example, you have a ball moving across the screen from left to right, but you also want that ball to wiggle. Rather than animating the Position property with keyframes, you can apply a wiggle expression to it.
The expressions language is based on the standard JavaScript language, but you do not need to know JavaScript to get started with expressions. You can create expressions by using the pick whip or by copying simple examples and modifying them to suit your needs. If you want to know more about it, see Understanding the Expressions language.
Here's a basic example of looping with expressions: