Pregunta de entrevista de Ex Libris

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