{"action":"created","issue":{"url":"https://api.github.com/repos/chanlumin/lumin/issues/2","repository_url":"https://api.github.com/repos/chanlumin/lumin","labels_url":"https://api.github.com/repos/chanlumin/lumin/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/chanlumin/lumin/issues/2/comments","events_url":"https://api.github.com/repos/chanlumin/lumin/issues/2/events","html_url":"https://github.com/chanlumin/lumin/issues/2","id":291156215,"number":2,"title":"阅读underscore","user":{"login":"chanlumin","id":27124693,"avatar_url":"https://avatars0.githubusercontent.com/u/27124693?v=4","gravatar_id":"","url":"https://api.github.com/users/chanlumin","html_url":"https://github.com/chanlumin","followers_url":"https://api.github.com/users/chanlumin/followers","following_url":"https://api.github.com/users/chanlumin/following{/other_user}","gists_url":"https://api.github.com/users/chanlumin/gists{/gist_id}","starred_url":"https://api.github.com/users/chanlumin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chanlumin/subscriptions","organizations_url":"https://api.github.com/users/chanlumin/orgs","repos_url":"https://api.github.com/users/chanlumin/repos","events_url":"https://api.github.com/users/chanlumin/events{/privacy}","received_events_url":"https://api.github.com/users/chanlumin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2018-01-24T10:26:51Z","updated_at":"2018-02-04T14:55:50Z","closed_at":null,"author_association":"OWNER","body":"#  基本的结构\r\n\r\n\r\n# typeof self === 'object' || self.self = self || self || typeof global === 'object' && global.global = global && global || this || {}\r\ntrue && true && self 返回的是self\r\n\r\n```javascript\r\n(function() {\r\n  var root = typeof self === 'object' && self.self === self && self ||\r\n  typeof global === 'object' && global === global && global ||\r\n  this ||\r\n  {}\r\n  // 保存原来的_对象 用于后面处理冲突\r\n  var previousUnderscore = root._\r\n  var _ = function(obj) {\r\n    if(obj instanceof _) return obj\r\n    if(!(this instanceof _)) return new _(obj)\r\n    this._wrapped = obj\r\n  }\r\n // 对node环境支持\r\n  if(typeof module != 'undefined' && module.exports != 'undefined') {\r\n    module.exports = _\r\n  } else {\r\n    root._ = _\r\n  }\r\n  // 实例方法\r\n  _.prototype.value = function () {\r\n    return this._wrapped\r\n  }\r\n  _.prototype.valueOf = _.prototype.toJSON = _.prototype.value\r\n  _.prototype.toString = function () {\r\n    return '' + this._wrapped\r\n  }\r\n  // 对amd 支持\r\n  if(typeof define === 'function' && defined.amd) {\r\n    define('underscore',[], function () {\r\n      return _\r\n    })\r\n  }\r\n\r\n})()\r\n```\r\n\r\n \r\n\r\n# 实现简单的浅拷贝 \r\n> 浅拷贝 只复制基本数据类型 比如   数字 字符串 \r\n>  浅拷贝当复制数组或者对象的时候  只会复制数组的地址 因此此时原对象和目标对象指的是同一个地址\r\n>  如果不要原对象和新对象有联系 那么就需要进行深复制\r\n```javascript\r\nfunction shallowCopy(obj) {\r\n     if(typeof obj == 'undefined') {return}\r\n    var dst = {}\r\n    for(var prop in obj) {\r\n        if(src.hasOwnProperty(src[prop]) {\r\n            dst[prop] = src[prop]\r\n         }\r\n    }\r\n    return dst\r\n}\r\n\r\n```\r\n\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/chanlumin/lumin/issues/comments/362912441","html_url":"https://github.com/chanlumin/lumin/issues/2#issuecomment-362912441","issue_url":"https://api.github.com/repos/chanlumin/lumin/issues/2","id":362912441,"user":{"login":"chanlumin","id":27124693,"avatar_url":"https://avatars0.githubusercontent.com/u/27124693?v=4","gravatar_id":"","url":"https://api.github.com/users/chanlumin","html_url":"https://github.com/chanlumin","followers_url":"https://api.github.com/users/chanlumin/followers","following_url":"https://api.github.com/users/chanlumin/following{/other_user}","gists_url":"https://api.github.com/users/chanlumin/gists{/gist_id}","starred_url":"https://api.github.com/users/chanlumin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chanlumin/subscriptions","organizations_url":"https://api.github.com/users/chanlumin/orgs","repos_url":"https://api.github.com/users/chanlumin/repos","events_url":"https://api.github.com/users/chanlumin/events{/privacy}","received_events_url":"https://api.github.com/users/chanlumin/received_events","type":"User","site_admin":false},"created_at":"2018-02-04T14:55:50Z","updated_at":"2018-02-04T14:55:50Z","author_association":"OWNER","body":"# isArrayLike\r\n> collection 可以翻译成对象  类数组要有 length属性 并且他所对应的值是number类型 而且要在数组最大的范围内\r\n  var MAX_ARRAY_INDEX = Math.pow(2,53) - 1\r\n  _.isArrayLike = function (collection) {\r\n    var length = collection !=null && collection.length\r\n    return typeof length == 'number' && length >=0 && length <= MAX_ARRAY_INDEX\r\n  }\r\n"}}
{"actor":{"display_login":"chanlumin"}}