JavaScript | Check whether a URL string is absolute or relative

The task is to check if the passed URL is absolute or relative. Below are the few approaches:
Approach 1: