Destroy object at a set distance

how would i destroy an object when it gets a set distance away from another ie a bullet from a gun.

For something like a bullet, I'd just use a timed destroy instead of distance (you'd do this when you instantiate):

Destroy(bullet, 5); //will destroy the bullet 5 seconds later

If you want to keep track of the bullet and destroy it when it's far away:

function Update()
{
    if (Vector3.Distance(transform.position, bullet.transform.position) > 20)
        Destroy(bullet);
}