Wikipedia: "A JavaScript library is a library of pre-written JavaScript which allows for easier development of JavaScript-based applications."
jQuery is an example of a popular library today. youtube.js is another example of a library, written by Pamela Fox, that contains pre-written JavaScript that you can use.
In the youtube.js library, there are four functions you can use:
youtube.getIdFromUrl(videoUrlOrID)Expects an argument (videoUrlOrID) that is either a youtube video URL or a video ID and returns back the video's ID.
var vid_id = youtube.getIdFromUrl('http://www.youtube.com/watch?v=epUk3T2Kfno'); //vid_id equals 'epUk3T2Kfno' (notice where the ID is in the original url)
youtube.generateThumbnailUrl(videoUrlOrID)Expects an argument (videoUrlOrID) that is either a youtube URL or a ID and returns back the URL of the thumbnail for that video.
var vid_thumbnail = youtube.generateThumbnailUrl('http://www.youtube.com/watch?v=epUk3T2Kfno'); //vid_thumbnail equals 'http://i3.ytimg.com/vi/epUk3T2Kfno/default.jpg' (notice how the video's ID is inserted in the middle of the image url)
youtube.generateWatchUrl(videoUrlOrID)Expects an argument (videoUrlOrID) that is either a youtube URL or a ID and returns back the URL for that video.
var vid_watch = youtube.generateWatchUrl('epUk3T2Kfno'); //vid_watch equals 'https://www.youtube.com/watch?v=epUk3T2Kfno' (notice where the video ID is in the url)
youtube.generateEmbedUrl(videoUrlOrID)Expects an argument (videoUrlOrID) that is either a youtube URL or a ID and returns back the embed URL for that video.
var vid_embed = youtube.generateEmbedUrl('http://www.youtube.com/watch?v=epUk3T2Kfno'); //vid_embed equals 'http://www.youtube.com/embed/epUk3T2Kfno' (notice where the video ID is in the url)