#### 命名空间
---
- 防止将变量使用在全局环境中;
- 必要时,可以使用自执行函数;
> <span class="do">正确实践:</span>
```js
function sum(){
var a = 10, b = 20;
return a + b;
}
(function($){
'use strict';
var postUrl = "/getUserName",
userName = "Jack";
$.ajax({
url : postUrl,
method : "post",
data : { userName : userName }
}).success(function(res){
//do sth.
});
})(jQuery)
```
> <span class="dont">错误实践:</span>
```js
var a = 10, b = 20;
function sum(){
return a + b;
}
```