Check out example codes for "check distance to gameobject". It will help you in understanding the concepts better.

Code Example 1

/// <summary>
/// Return distance between two points
/// </summary>
/// <param name="target"></param>
/// <param name="startPos"></param>
/// <returns></returns>
public float CheckDistanceTwoPoints(Vector3 target, Vector3 startPos)
{
	return Vector3.Distance(target, startPos);
}

Learn ReactJs, React Native from akashmittal.com