{"id":632,"date":"2012-08-22T05:05:47","date_gmt":"2012-08-22T05:05:47","guid":{"rendered":"http:\/\/codeatelier.wordpress.com\/?p=239"},"modified":"2016-09-10T14:50:11","modified_gmt":"2016-09-10T14:50:11","slug":"working-with-javascript-arrays","status":"publish","type":"post","link":"https:\/\/codethataint.com\/blog\/working-with-javascript-arrays\/","title":{"rendered":"Working with javascript Arrays"},"content":{"rendered":"<p><strong>How to Split CSV into array <\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n   csvProjectIds = '1,2,3,4';\r\n   arrProjectIds = csvProjectIds.split(',');\t\t\t\t\r\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<pre>\r\n     arrProjectIds[0] = 1\r\n     arrProjectIds[1] = 2\r\n     arrProjectIds[2] = 3\r\n     arrProjectIds[3] = 4\r\n<\/pre>\n<p><strong>How to Find Element is in Array<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n   csvProjectIds = '1,2,3,4';\r\n   arrProjectIds = csvProjectIds.split(',');\t\t\t\t\r\n   alert(arrProjectIds.indexOf('1'));\r\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<pre>\r\n 0\r\n<\/pre>\n<p>The indexOf Returns 0 incase the element is in the array or<br \/>\n                    -1 if not in the array   <\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Split CSV into array csvProjectIds = &#8216;1,2,3,4&#8217;; arrProjectIds = csvProjectIds.split(&#8216;,&#8217;); Output arrProjectIds[0] = 1 arrProjectIds[1] = 2 arrProjectIds[2] = 3 arrProjectIds[3] = 4 How to Find Element is in Array csvProjectIds = &#8216;1,2,3,4&#8217;; arrProjectIds = csvProjectIds.split(&#8216;,&#8217;); alert(arrProjectIds.indexOf(&#8216;1&#8217;)); Output 0 The indexOf Returns 0 incase the element is in the array or -1 if&hellip; <a href=\"https:\/\/codethataint.com\/blog\/working-with-javascript-arrays\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[119],"tags":[],"class_list":["post-632","post","type-post","status-publish","format-standard","hentry","category-arrays-javascript"],"_links":{"self":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/632","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/comments?post=632"}],"version-history":[{"count":3,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/632\/revisions"}],"predecessor-version":[{"id":1594,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/632\/revisions\/1594"}],"wp:attachment":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/media?parent=632"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/categories?post=632"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/tags?post=632"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}