Note: I know fuckall about JavaScript, but: - The "var power" bit stores the following function into a variable called "power", which you can then call. - Definition of the power function would be something like: base^exponent = base x base x base x ... (exponent times) - Also note, edge case: base^0 = 1 (except for base = 0) Then see how inside the loop you're computing a new value for result using result and base as input? That's why result has to be initialised, to handle both the edge case and so the loop works; as for the first iteration you're just computing result = 1 * base (i.e. base^1).