How do I make an object follow the mouse in javascript?

Does anyone know? The z will be on the terrains.

I am assuming that you are viewing the object from an aerial perspective and you have an object that you want to follow your mouse along a terrain. Please be more specific in the future, but here is my interpretation.

What you are trying to find is a Vector3 that represents where you would like to snap your object to. There are several ways you could accomplish this, however I think that the easiest way should be for you to cast a ray from your viewport through the mouse position and use RaycastHit.point to find exactly where your ray is intersecting your terrain. I haven't used Terrains very much but I believe that should work. That should read out the vector3 position which from the camera's perspective is exactly where your mouse is. Some adjustments may be required for ideal placement.