{"action":"created","issue":{"url":"https://api.github.com/repos/plainnany/blog/issues/17","repository_url":"https://api.github.com/repos/plainnany/blog","labels_url":"https://api.github.com/repos/plainnany/blog/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/plainnany/blog/issues/17/comments","events_url":"https://api.github.com/repos/plainnany/blog/issues/17/events","html_url":"https://github.com/plainnany/blog/issues/17","id":244214404,"number":17,"title":"JS 4","user":{"login":"plainnany","id":27320655,"avatar_url":"https://avatars0.githubusercontent.com/u/27320655?v=4","gravatar_id":"","url":"https://api.github.com/users/plainnany","html_url":"https://github.com/plainnany","followers_url":"https://api.github.com/users/plainnany/followers","following_url":"https://api.github.com/users/plainnany/following{/other_user}","gists_url":"https://api.github.com/users/plainnany/gists{/gist_id}","starred_url":"https://api.github.com/users/plainnany/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plainnany/subscriptions","organizations_url":"https://api.github.com/users/plainnany/orgs","repos_url":"https://api.github.com/users/plainnany/repos","events_url":"https://api.github.com/users/plainnany/events{/privacy}","received_events_url":"https://api.github.com/users/plainnany/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-07-20T00:43:56Z","updated_at":"2017-07-20T02:13:16Z","closed_at":null,"body":"## 1.引用类型有哪些？非引用类型有哪些\r\n\r\n引用类型有对象、数组、函数、正则，指的是那些保存在堆内存中的对象，变量中保存的实际上只是一个指针，这个指针执行内存中的另一个位置，由该位置保存对象。\r\n非引用类型有数值、布尔值、null和undefined，指的是保存在栈内存中的简单数据段。\r\n## 2.如下代码输出什么？为什么\r\n```\r\nvar obj1 = {a:1, b:2};\r\nvar obj2 = {a:1, b:2};\r\nconsole.log(obj1 == obj2);  // false   obj1和obj2指向内存中不同的位置\r\nconsole.log(obj1 = obj2);   {a: 1,b:2}   将obj1的指针指向obj2指向的位置，obj1和obj2指向同一个内存位置\r\nconsole.log(obj1 == obj2);  // true   如上。\r\n```\r\n## 3.如下代码输出什么? 为什么\r\n```\r\nvar a = 1\r\nvar b = 2\r\nvar c = { name: '饥人谷', age: 2 }\r\nvar d = [a, b, c]\r\n\r\nvar aa = a\r\nvar bb = b\r\nvar cc = c\r\nvar dd = d\r\n\r\na = 11\r\nb = 22\r\nc.name = 'hello'\r\nd[2]['age'] = 3\r\n\r\nconsole.log(aa)    // 1  \r\nconsole.log(bb)   // 2\r\nconsole.log(cc)   //  {name: 'hello', age: '2'}\r\nconsole.log(dd)  //  [1, 2, {name: 'hello', age: '3' }]\r\n```\r\n## 4.如下代码输出什么? 为什么\r\n```\r\nvar a = 1\r\nvar c = { name: 'jirengu', age: 2 }\r\n\r\nfunction f1(n){\r\n  ++n\r\n}\r\nfunction f2(obj){\r\n  ++obj.age\r\n}\r\n\r\nf1(a)  \r\nf2(c) \r\nf1(c.age) \r\nconsole.log(a)   // 1\r\nconsole.log(c)   // 3\r\n```\r\n## 5.过滤如下数组，只保留正数，直接在原数组上操作\r\n```\r\nvar arr = [3,1,0,-1,-3,2,-5]\r\nfunction filter(arr){\r\n  for(var i=0;i<arr.length;i++){\r\n      if(arr[i]<=0){\r\n          arr.splice(i,1)\r\n\t  filter(arr)\r\n      }\t\t\r\n  }\r\n}\r\nfilter(arr)\r\nconsole.log(arr) // [3,1,2]\r\n```\r\n## 6.过滤如下数组，只保留正数，原数组不变，生成新数组\r\n```\r\nvar arr = [3,1,0,-1,-3,2,-5]\r\nfunction filter(arr){\r\n  var result=[]\r\n  for(var i=0;i<arr.length;i++){\r\n      if(arr[i]>0){\r\n          result.push(arr[i])\r\n      }\t\t\r\n  }\r\n  return result\r\n}\r\nvar arr2 = filter(arr)\r\nconsole.log(arr2) // [3,1,2]\r\nconsole.log(arr)  // [3,1,0,-1,-2,2,-5]\r\n```\r\n## 7.写一个深拷贝函数，用两种方式实现"},"comment":{"url":"https://api.github.com/repos/plainnany/blog/issues/comments/316576176","html_url":"https://github.com/plainnany/blog/issues/17#issuecomment-316576176","issue_url":"https://api.github.com/repos/plainnany/blog/issues/17","id":316576176,"user":{"login":"plainnany","id":27320655,"avatar_url":"https://avatars0.githubusercontent.com/u/27320655?v=4","gravatar_id":"","url":"https://api.github.com/users/plainnany","html_url":"https://github.com/plainnany","followers_url":"https://api.github.com/users/plainnany/followers","following_url":"https://api.github.com/users/plainnany/following{/other_user}","gists_url":"https://api.github.com/users/plainnany/gists{/gist_id}","starred_url":"https://api.github.com/users/plainnany/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plainnany/subscriptions","organizations_url":"https://api.github.com/users/plainnany/orgs","repos_url":"https://api.github.com/users/plainnany/repos","events_url":"https://api.github.com/users/plainnany/events{/privacy}","received_events_url":"https://api.github.com/users/plainnany/received_events","type":"User","site_admin":false},"created_at":"2017-07-20T02:13:16Z","updated_at":"2017-07-20T02:13:16Z","body":"关于深拷贝和浅拷贝\r\n[javascript中的深拷贝和浅拷贝？](https://www.zhihu.com/question/23031215)"}}
{"actor":{"display_login":"plainnany"}}