首页 > Web开发 > 详细

underscore.js 分析 第三天

时间:2014-09-15 15:49:29      阅读:171      评论:0      收藏:0      [点我收藏+]
  // Create a safe reference to the Underscore object for use below.
  // 为Underscore对象创建一个安全的引用
  // _为一个函数对象,它的实例服从单例模式。
  var _ = function(obj) {
    if (obj instanceof _) return obj;
    if (!(this instanceof _)) return new _(obj);
    this._wrapped = obj;
  };

来一个最简单的例子

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Underscore</title>
    <script src="underscore.js"></script>
</head>
<body>
</body>
</html>


<script type="text/javascript">
// 在浏览器中 _ 是全局对象
// 查看Underscore的当前版本
alert(_.VERSION);
</script>

 

underscore.js 分析 第三天

原文:http://www.cnblogs.com/mafeifan/p/3972884.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!