You can organize your javascript code using design patterns. You have to decide the design patterns which you are going to use based on the project.