  We use a high-resolution $N$-body simulation to study how the formation of
cold dark matter (CDM) halos is affected by their environments, and how such
environmental effects produce the age-dependence of halo clustering observed in
recent $N$-body simulations. We estimate, for each halo selected at redshift
$z=0$, an `initial' mass $M_{\rm i}$ defined to be the mass enclosed by the
largest sphere which contains the initial barycenter of the halo particles and
within which the mean linear density is equal to the critical value for
spherical collapse at $z=0$. For halos of a given final mass, $M_{\rm h}$, the
ratio $M_{\rm i}/M_{\rm h}$ has large scatter, and the scatter is larger for
halos of lower final masses. Halos that form earlier on average have larger
$M_{\rm i}/M_{\rm h}$, and so correspond to higher peaks in the initial density
field than their final masses imply. Old halos are more strongly clustered than
younger ones of the same mass because their initial masses are larger. The
age-dependence of clustering for low-mass halos is entirely due to the
difference in the initial/final mass ratio. Low-mass old halos are almost
always located in the vicinity of big structures, and their old ages are
largely due to the fact that their mass accretions are suppressed by the hot
environments produced by the tidal fields of the larger structure. The
age-dependence of clustering is weaker for more massive halos because the
heating by large-scale tidal fields is less important.
