javascript pattern(2) - Factory pattern