Share a JavaScript library's namespace or use your own? -


It is well known in Javascript that declaring variables within the global scope is a bad thing I work in it contain nominated javascript.

It seems that it takes two different ways -

  1. Adding your application specific function to the namespace of libraries eg $ MyCarouselfunction
  2. Create your own namespace Example MyApplication.myCarouselFunction

I wanted to know if there is a better solution or not, if they In the case of professionals and opposition, they get closer.

The reason for me is that the decision not to go personally with the library is for the alienation of separation / separation / conflicts of conflict with the library code and the potential plugin for the possibility of sharing that namespace. Is this not being considered more?

I think the most important thing to choose is semantics

Does your function / class expand or depend on library-specific features? Keep it in the library name space

Is your function / category library independent? In this case, it is better to put it in a custom namespace, it makes it possible to reuse your code out of the library, which you originally used it.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -