{"id":10565,"date":"2020-05-09T19:30:36","date_gmt":"2020-05-09T10:30:36","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=10565"},"modified":"2023-05-27T20:55:52","modified_gmt":"2023-05-27T11:55:52","slug":"%e3%80%90javascript%e3%80%91%e9%85%8d%e5%88%97%e3%81%ae%e4%be%bf%e5%88%a9%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89%e3%80%8cevery%e3%80%8d%e3%82%84%e3%80%8csome%e3%80%8d","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=10565","title":{"rendered":"\u3010JavaScript\u3011\u914d\u5217\u306e\u4fbf\u5229\u30e1\u30bd\u30c3\u30c9\u300cevery\u300d\u3084\u300csome\u300d"},"content":{"rendered":"<h2>every<\/h2>\n<p><span style=\"color: #ff0000;\"><strong>\u8ad6\u7406\u7a4d<\/strong><\/span>\u3092\u8fd4\u3057\u307e\u3059\u3002\u8981\u306f\u3001\u914d\u5217\u306e\u8981\u7d20\u306e\u4e2d\u306e\u5168\u3066\u306e\u5224\u5b9a\u304ctrue\u306e\u5834\u5408\u306ftrue\u304c\u8fd4\u308a\u307e\u3059\u3002\u914d\u5217\u306e\u8981\u7d20\u306e\u4e2d\u3067\u4e00\u3064\u3067\u3082false\u3068\u5224\u5b9a\u3055\u308c\u305f\u5834\u5408\u306ffalse\u304c\u8fd4\u308a\u307e\u3059\u3002<\/p>\n<h3>every\u306e\u4f7f\u3044\u6240<\/h3>\n<p>\u30d5\u30a9\u30fc\u30e0\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3067\u5168\u3066\u901a\u904e\u3057\u3066\u3044\u306a\u3044\u3068\u30c0\u30e1\u306a\u5834\u5408\u7b49\u306b\u30b3\u30fc\u30c9\u3092\u6574\u7406\u3059\u308b\u306e\u306b\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">let fields = [\r\n  new Field('name'), \/\/\u30d5\u30a9\u30fc\u30e0\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u30af\u30e9\u30b9\r\n  new Field('password'),\r\n  new Field('gender')\r\n]\r\n\r\n\/\/\u5168\u3066\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306b\u901a\u904e\u3057\u306a\u3044\u3068false\u306b\u306a\u308b\u3002\r\nfields.every(function(field){\r\n  return field.validate(); \/\/validate\u95a2\u6570\u306ftrue or false\u3092\u8fd4\u3059\u95a2\u6570\r\n});<\/pre>\n<h3>\u4f8b<\/h3>\n<h4>true<\/h4>\n<pre class=\"lang:default decode:true\">let cats = [\r\n  { name:'\u592a\u90ce',weight:25 },\r\n  { name:'\u82b1\u5b50',weight:35 },\r\n  { name:'\u6b21\u90ce',weight:45 }\r\n]\r\n\r\nlet newCats = cats.every(function(cat){\r\n  return cat.weight &gt; 24;\r\n})\r\nnewCats; \/\/true<\/pre>\n<h4>false<\/h4>\n<pre class=\"lang:default decode:true\">let cats = [\r\n  { name:'\u592a\u90ce',weight:25 },\r\n  { name:'\u82b1\u5b50',weight:35 },\r\n  { name:'\u6b21\u90ce',weight:45 }\r\n]\r\n\r\nlet newCats = cats.every(function(cat){\r\n  return cat.weight &gt; 25;\r\n})\r\nnewCats; \/\/false<\/pre>\n<h2>some<\/h2>\n<p><span style=\"color: #ff0000;\"><strong>\u8ad6\u7406\u548c<\/strong><\/span>\u3092\u8fd4\u3057\u307e\u3059\u3002every\u3068\u306f\u9006\u3067\u914d\u5217\u306e\u8981\u7d20\u5185\u306e\u3069\u308c\u304b\u4e00\u3064\u3067\u3082true\u3060\u3063\u305f\u5834\u5408\u306ftrue\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<h3>some\u306e\u4f7f\u3044\u6240<\/h3>\n<ul>\n<li>\u5177\u4f53\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u306f\u3053\u3053\u3067\u306f\u6319\u3052\u307e\u305b\u3093\u304c\u3001\u30b9\u30c6\u30fc\u30bf\u30b9\u7ba1\u7406\u3057\u3066\u3044\u308b\u3088\u3046\u306a\u30c7\u30fc\u30bf\u304c\u3042\u3063\u305f\u5834\u5408\u306b<span style=\"color: #ff0000;\"><strong>\u4e00\u3064\u3067\u3082\u7279\u5b9a\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u306b\u306a\u3063\u3066\u3044\u305f\u3089<\/strong><\/span>\u307f\u305f\u3044\u306a\u51e6\u7406\u3092\u8a18\u8ff0\u3059\u308b\u5834\u5408\u306b\u4f7f\u3048\u308b\u3067\u3057\u3087\u3046\u3002<\/li>\n<\/ul>\n<h3>\u4f8b<\/h3>\n<h4>true<\/h4>\n<pre class=\"lang:default decode:true \">let cats = [\r\n  { name:'\u592a\u90ce',weight:25 },\r\n  { name:'\u82b1\u5b50',weight:35 },\r\n  { name:'\u6b21\u90ce',weight:45 }\r\n]\r\n\r\nlet newCats = cats.some(function(cat){\r\n  return cat.weight &gt; 44;\r\n})\r\nnewCats; \/\/true<\/pre>\n<h4>false<\/h4>\n<pre class=\"lang:default decode:true  \">let cats = [\r\n  { name:'\u592a\u90ce',weight:25 },\r\n  { name:'\u82b1\u5b50',weight:35 },\r\n  { name:'\u6b21\u90ce',weight:45 }\r\n]\r\n\r\nlet newCats = cats.some(function(cat){\r\n  return cat.weight &gt; 45;\r\n})\r\nnewCats; \/\/false<\/pre>\n","protected":false},"excerpt":{"rendered":"every \u8ad6\u7406\u7a4d\u3092\u8fd4\u3057\u307e\u3059\u3002\u8981\u306f\u3001\u914d\u5217\u306e\u8981\u7d20\u306e\u4e2d\u306e\u5168\u3066\u306e\u5224\u5b9a\u304ctrue\u306e\u5834\u5408\u306ftrue\u304c\u8fd4\u308a\u307e\u3059\u3002\u914d\u5217\u306e\u8981\u7d20\u306e\u4e2d\u3067\u4e00\u3064\u3067\u3082false\u3068\u5224\u5b9a\u3055\u308c\u305f\u5834\u5408\u306ffalse\u304c\u8fd4\u308a\u307e\u3059\u3002 every\u306e\u4f7f\u3044\u6240 \u30d5\u30a9\u30fc\u30e0\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3 [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/10565"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10565"}],"version-history":[{"count":8,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/10565\/revisions"}],"predecessor-version":[{"id":20282,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/10565\/revisions\/20282"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10565"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10565"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10565"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}