DEV Community

Discussion on: I am not able to understand 'factory'

 
webjayant profile image
Jayant Raj Singh

The problem is with the way the code is formatted.


;(function(factory){
    ...
    ...
}(function (){
    ...
    ...
}))

the code formatted like above thus there is no error and the code works fine.

The only problem is that this type of formatting creates a lot of confusion (It took me two days, and your help in deciphering it)

this would have been a better approach

function factory (){
    ...
    ...
}

(function(factory){
    ...
    ...
})()
Thread Thread
 
somedood profile image
Basti Ortiz

Yup, agreed. Perhaps you could submit a pull request to format the code. That way, you can help people who are just as curious of the code understand it better. Contributions are always welcome (and needed) in the open-source world.