{"action":"closed","issue":{"url":"https://api.github.com/repos/chen77/vue-prac/issues/3","repository_url":"https://api.github.com/repos/chen77/vue-prac","labels_url":"https://api.github.com/repos/chen77/vue-prac/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/chen77/vue-prac/issues/3/comments","events_url":"https://api.github.com/repos/chen77/vue-prac/issues/3/events","html_url":"https://github.com/chen77/vue-prac/issues/3","id":307541558,"number":3,"title":"find()和findIndex()详解","user":{"login":"chen77","id":10527493,"avatar_url":"https://avatars3.githubusercontent.com/u/10527493?v=4","gravatar_id":"","url":"https://api.github.com/users/chen77","html_url":"https://github.com/chen77","followers_url":"https://api.github.com/users/chen77/followers","following_url":"https://api.github.com/users/chen77/following{/other_user}","gists_url":"https://api.github.com/users/chen77/gists{/gist_id}","starred_url":"https://api.github.com/users/chen77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chen77/subscriptions","organizations_url":"https://api.github.com/users/chen77/orgs","repos_url":"https://api.github.com/users/chen77/repos","events_url":"https://api.github.com/users/chen77/events{/privacy}","received_events_url":"https://api.github.com/users/chen77/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-22T08:07:33Z","updated_at":"2018-03-22T08:08:27Z","closed_at":"2018-03-22T08:08:27Z","author_association":"OWNER","body":"## find()\r\n- find() 方法返回传入一个测试条件（函数）**符合条件的数组第一个元素**\r\n**find() 并没有改变数组的原始值。**\r\nfind() 方法为数组中的每个元素都调用一次函数执行：\r\n>当数组中的元素在测试条件时返回 true 时, find() 返回符合条件的元素，之后的值不会再调用执行函数。\r\n如果没有符合条件的元素返回 undefined\r\n```js\r\nvar arr=[1,2,3,4,5];\r\nvar a=arr.find(function(num){\r\n   return num>2;\r\n});\r\nconsole.log(a)//3\r\n```\r\nIE 11 及更早版本不支持 find() 方法。\r\n## findIndex()\r\n- findIndex() 方法返回传入一个测试条件（函数）符合条件的数组第一个元素位置。\r\n- findIndex() 方法为数组中的每个元素都调用一次函数执行：\r\n当数组中的元素在测试条件时返回 true 时, findIndex() 返回符合条件的元素的索引位置，之后的值不会再调用执行函数。\r\n如果没有符合条件的元素返回 -1"}}
{"actor":{"display_login":"chen77"}}