{"id":237,"date":"2017-03-26T21:15:39","date_gmt":"2017-03-26T21:15:39","guid":{"rendered":"http:\/\/www.onux.com\/jspp\/blog\/?p=237"},"modified":"2017-03-26T21:21:07","modified_gmt":"2017-03-26T21:21:07","slug":"js-0-5-1-foreach","status":"publish","type":"post","link":"https:\/\/www.onux.com\/jspp\/blog\/js-0-5-1-foreach\/","title":{"rendered":"JS++ 0.5.1: &#8216;foreach&#8217;"},"content":{"rendered":"<p>We just released JS++ 0.5.1, which features the <a href=\"https:\/\/docs.onux.com\/en-US\/Developers\/JavaScript-PP\/Language\/Reference\/Statements\/foreach\"><code>foreach<\/code> keyword<\/a>.<\/p>\n<p>Basic usage is as follows:<\/p>\n<pre class=\"brush: jspp\">\r\nexternal console;\r\n\r\nint[] arr = [ 50, 40, 30 ];\r\n\r\nforeach (int value in arr) {\r\n    console.log(value);\r\n}\r\n\r\n\/\/ Output:\r\n\/\/ 50\r\n\/\/ 40\r\n\/\/ 30\r\n<\/pre>\n<p>More complex usage, such as arrays of objects, are also possible:<\/p>\n<pre class=\"brush: jspp\">\r\nexternal console;\r\n\r\nclass Foo\r\n{\r\n\tstring bar() {\r\n\t\treturn \"bar\";\r\n\t}\r\n}\r\n\r\nFoo[] foo = [ new Foo(), new Foo(), new Foo() ];\r\n\r\nforeach (Foo value in foo) {\r\n    console.log(value.bar());\r\n}\r\n\r\n\/\/ Output:\r\n\/\/ \"bar\"\r\n\/\/ \"bar\"\r\n\/\/ \"bar\"\r\n<\/pre>\n<p>Additionally, the <a href=\"https:\/\/docs.onux.com\/en-US\/Developers\/JavaScript-PP\/Language\/Reference\/Statements\/for-in\"><code>for-in<\/code> keyword<\/a> has been implemented. It is a counterpart to the <code>foreach<\/code> keyword in the sense that it enumerates keys rather than values.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We just released JS++ 0.5.1, which features the foreach keyword. Basic usage is as follows: external console; int[] arr = [ 50, 40, 30 ]; foreach (int value in arr) { console.log(value); } \/\/ Output: \/\/ 50 \/\/ 40 \/\/ 30 More complex usage, such as arrays of objects, are also possible: external console; class &hellip; <a href=\"https:\/\/www.onux.com\/jspp\/blog\/js-0-5-1-foreach\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;JS++ 0.5.1: &#8216;foreach&#8217;&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[2,4],"tags":[],"_links":{"self":[{"href":"https:\/\/www.onux.com\/jspp\/blog\/wp-json\/wp\/v2\/posts\/237"}],"collection":[{"href":"https:\/\/www.onux.com\/jspp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.onux.com\/jspp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.onux.com\/jspp\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.onux.com\/jspp\/blog\/wp-json\/wp\/v2\/comments?post=237"}],"version-history":[{"count":5,"href":"https:\/\/www.onux.com\/jspp\/blog\/wp-json\/wp\/v2\/posts\/237\/revisions"}],"predecessor-version":[{"id":242,"href":"https:\/\/www.onux.com\/jspp\/blog\/wp-json\/wp\/v2\/posts\/237\/revisions\/242"}],"wp:attachment":[{"href":"https:\/\/www.onux.com\/jspp\/blog\/wp-json\/wp\/v2\/media?parent=237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.onux.com\/jspp\/blog\/wp-json\/wp\/v2\/categories?post=237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.onux.com\/jspp\/blog\/wp-json\/wp\/v2\/tags?post=237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}