Ex Libris interview question

What is a factory design pattern, and how to implement it in javascript?