

{"id":64172,"date":"2019-08-01T17:14:52","date_gmt":"2019-08-01T11:44:52","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=64172"},"modified":"2021-02-17T21:32:32","modified_gmt":"2021-02-17T16:02:32","slug":"javascript-array","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/javascript-array\/","title":{"rendered":"JavaScript Array &#8211; A Complete Guide for Beginners!"},"content":{"rendered":"<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:1454,&quot;href&quot;:&quot;https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/JavaScript&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20251208180004\\\/https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/JavaScript&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-09 07:25:01&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-12 10:12:19&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-19 20:12:26&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-23 14:26:43&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-26 20:33:05&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-30 03:46:49&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-03 10:04:10&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-08 07:59:48&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-11 13:08:47&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-16 08:13:22&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-20 13:51:36&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-24 03:23:30&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-28 01:26:04&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-31 06:28:41&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-03 10:56:46&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-10 05:25:16&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-13 14:40:22&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-16 17:27:49&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-20 11:10:49&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-26 10:59:31&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-02 23:12:45&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-07 09:23:37&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-16 15:08:09&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-20 11:51:02&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-26 05:27:11&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-01 15:53:39&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-05 04:38:58&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-10 05:37:32&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-14 10:47:54&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-17 11:57:53&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-21 02:42:11&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-24 09:17:36&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-28 02:46:05&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-01 07:17:08&quot;,&quot;http_code&quot;:429},{&quot;date&quot;:&quot;2026-05-05 18:21:06&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-11 11:12:51&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-14 16:04:50&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-17 16:56:01&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-21 17:58:16&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-25 08:21:54&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-30 04:19:24&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-02 22:21:06&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-06-06 18:08:05&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-06 18:08:05&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]'><\/div>\n<p>Earlier in our previous tutorial, we read about <em><strong><a href=\"https:\/\/data-flair.training\/blogs\/javascript-event-types\/\">JavaScript Event Types<\/a>.<\/strong><\/em> Moving ahead, now we will learn about JavaScript Array. In this article, we will understand what\u00a0are arrays, how to create and work with them. We will discuss various methods to access, add\/remove or manipulate a JavaScript Array. Last but not the least we will also go through the different types of arrays provided by JavaScript. The tutorial also includes some of the properties and methods you can use in an array.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/how-to-create-JavaScript-array.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-66565\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/how-to-create-JavaScript-array.jpg\" alt=\"how to create JavaScript Array\" width=\"801\" height=\"418\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/how-to-create-JavaScript-array.jpg 801w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/how-to-create-JavaScript-array-150x78.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/how-to-create-JavaScript-array-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/how-to-create-JavaScript-array-768x401.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/how-to-create-JavaScript-array-520x271.jpg 520w\" sizes=\"auto, (max-width: 801px) 100vw, 801px\" \/><\/a><\/p>\n<p>So without wasting any time, let&#8217;s start with our best tutorial on JavaScript Array.<\/p>\n<h2>What is JavaScript Array?<\/h2>\n<p>Before starting with this tutorial, I would recommend you to read our tutorial on <a href=\"https:\/\/data-flair.training\/blogs\/javascript-objects\/\"><em><strong>JavaScript Objects<\/strong><\/em><\/a> first. Because, you cannot learn JavaScript Arrays until and unless you understand JavaScript Objects. Arrays are a very powerful tool in JavaScript. The definition of an array in Java goes something like this:<em> \u201cAn array is a collection of homogeneous elements, stored in a contiguous memory location.\u201d<\/em><\/p>\n<p>In JavaScript, while the memory location is still contiguous, homogenous elements are no longer required. This is because, in Java, we have to pre-decide the type of array we want to use. JavaScript has no such obligation. It\u2019s perfectly fine to define an array with the following values:<strong> \u201cNeha\u201d, \u201cDataFlair Web Services\u201d, 26, 3.5, true<\/strong>. This is the array we will create in this tutorial. Let me explain the values a bit. Neha is an employee, age <strong>26<\/strong>, of the company <strong>DataFlair Web Services.<\/strong> She has 3.5 years of work experience under her belt and her status for still working is <strong>true.<\/strong><\/p>\n<p>But you need to be very careful when you use this functionality in your program. You must define the array like this only if your array makes sense. If it doesn\u2019t, you\u2019ll create a mess in your program that will be very difficult to resolve. Also, unlike C, JavaScript Arrays have no fixed size. Thus, we can allocate memory to a new array element anywhere in the program we wish.<\/p>\n<h3>Create an Array in JavaScript<\/h3>\n<p>Since an array is a list-like object, there are three methods to create an array as well. The difference is that we use <strong>square brackets [ ]<\/strong> for arrays instead of <strong>curly braces { }<\/strong>. Let\u2019s see the different methods for array creation in a little more detail.<\/p>\n<h4>1. Array Literal Method<\/h4>\n<p>The syntax to create an array literal is as follows:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">var arrayName = [val1, val2, val3, \u2026, valN];<\/pre>\n<p>JavaScript code to create the array using the literal method is given below:<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;html&gt;\r\n  &lt;body&gt;\r\n    &lt;script&gt;\r\n      \/\/creating an array with literal method\r\n      var array1 = [\"Neha\", \"DataFlair Web Services\", 26, 3.5, true];\r\n      \/\/accessing the values of the array\r\n      document.write(\"Employee: \" + array1[0] + \"&lt;\/br&gt;\");\r\n      document.write(\"Company: \" + array1[1] + \"&lt;\/br&gt;\");\r\n      document.write(\"Age: \" + array1[2] + \"&lt;\/br&gt;\");\r\n      document.write(\"Work Experience: \" + array1[3] + \"&lt;\/br&gt;\");\r\n      document.write(\"Still Working?: \" + array1[4] + \"&lt;\/br&gt;\");\r\n    &lt;\/script&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><strong>Screenshot:<\/strong><\/p>\n<h4><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_literal.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-65563\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_literal.jpg\" alt=\"array_literal\" width=\"1298\" height=\"740\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_literal.jpg 1298w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_literal-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_literal-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_literal-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_literal-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_literal-520x296.jpg 520w\" sizes=\"auto, (max-width: 1298px) 100vw, 1298px\" \/><\/a><\/h4>\n<p><strong>Output:<\/strong><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_literal-op.jpg\"><br \/>\n<\/a><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_literal-op.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"img-gray-border aligncenter wp-image-65564 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_literal-op.jpg\" alt=\"array_literal op\" width=\"1298\" height=\"743\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_literal-op.jpg 1298w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_literal-op-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_literal-op-300x172.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_literal-op-768x440.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_literal-op-1024x586.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_literal-op-520x298.jpg 520w\" sizes=\"auto, (max-width: 1298px) 100vw, 1298px\" \/><\/a><\/p>\n<h4>2. Array Instance Method<\/h4>\n<p>Similar to objects, we use the<strong> new<\/strong> keyword to create the instance of an array. The syntax of creating an array using this method is as follows:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">var arrayName = new Array( );\r\n<\/pre>\n<p>To add new elements in an array, we use the bracket notation.<\/p>\n<p>The code below produces the same output as above.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;html&gt;\r\n  &lt;body&gt;\r\n\r\n    &lt;script&gt;\r\n      var array2 = new Array(); \/\/creating an instance of the array\r\n      \/\/adding values\r\n      array2[0] = \"Neha\";\r\n      array2[1] = \"DataFlair Web Services\";\r\n      array2[2] = 26;\r\n      array2[3] = 3.5;\r\n      array2[4] = true;\r\n      \/\/accessing the values of the array\r\n      document.write(\"Employee: \" + array2[0] + \"&lt;\/br&gt;\");\r\n      document.write(\"Working for: \" + array2[1] + \"&lt;\/br&gt;\");\r\n      document.write(\"Age: \" + array2[2] + \"&lt;\/br&gt;\");\r\n      document.write(\"Work Experience: \" + array2[3] + \"&lt;\/br&gt;\");\r\n      document.write(\"Still Working?: \" + array2[4] + \"&lt;\/br&gt;\");\r\n    &lt;\/script&gt;\r\n\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p><strong>Screenshot:<\/strong><\/p>\n<h4><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_instance.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-65565\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_instance.jpg\" alt=\"array_instance\" width=\"1299\" height=\"736\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_instance.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_instance-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_instance-300x170.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_instance-768x435.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_instance-1024x580.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_instance-520x295.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/h4>\n<h4>3. Array Constructor Method<\/h4>\n<p>The syntax to create an array with the help of the constructor method is as follows:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">var arrayName = new Array(val1, val2, val3, \u2026, valN);<\/pre>\n<p>The code below will yield the same output as the above two methods.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;html&gt;\r\n  &lt;body&gt;\r\n\r\n    &lt;script&gt;\r\n      \/\/creating an array with constructor method\r\n      var array3 = new Array(\"Neha\", \"DataFlair Web Services\", 26, 3.5, true);\r\n      \/\/accessing the values of the array\r\n      document.write(\"Employee: \" + array3[0] + \"&lt;\/br&gt;\");\r\n      document.write(\"Working for: \" + array3[1] + \"&lt;\/br&gt;\");\r\n      document.write(\"Age: \" + array3[2] + \"&lt;\/br&gt;\");\r\n      document.write(\"Work Experience: \" + array3[3] + \"&lt;\/br&gt;\");\r\n      document.write(\"Still Working?: \" + array3[4] + \"&lt;\/br&gt;\");\r\n    &lt;\/script&gt;\r\n\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;\r\n\r\n<\/pre>\n<p><strong>Screenshot:<\/strong><\/p>\n<h4><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_constructor.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-65567\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_constructor.jpg\" alt=\"array_constructor\" width=\"1298\" height=\"740\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_constructor.jpg 1298w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_constructor-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_constructor-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_constructor-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_constructor-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/array_constructor-520x296.jpg 520w\" sizes=\"auto, (max-width: 1298px) 100vw, 1298px\" \/><\/a><\/h4>\n<h4>4. To Copy an Array<\/h4>\n<p>We use the <strong>slice()<\/strong> method in JavaScript to create a copy of an array. We can either copy the whole array or a part of it. It\u2019s our choice, all you need to do is specify the start and end positions of the array. The syntax of a slice() method is as follows:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">var newArrayName = oldArray.slice(start, end)\r\n<\/pre>\n<p>If you pass an empty method to the compiler, i.e. slice(), it will copy the complete array to the new array. Add the following codes in the compiler to copy the entire array and part of it respectively.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">var newArray = array1.slice()<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">var newArray = array1.slice(start, end)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/slice.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"img-gray-border aligncenter wp-image-65571 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/slice.jpg\" alt=\"slice\" width=\"1301\" height=\"743\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/slice.jpg 1301w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/slice-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/slice-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/slice-768x439.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/slice-1024x585.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/slice-520x297.jpg 520w\" sizes=\"auto, (max-width: 1301px) 100vw, 1301px\" \/><\/a><\/p>\n<p><em><strong>Take a deep dive into our tutorial on <a href=\"https:\/\/data-flair.training\/blogs\/javascript-variable-tutorial\/\">JavaScript Variable<\/a><\/strong><\/em><\/p>\n<h3>Associative Array in JavaScript<\/h3>\n<p>We created an array object in the above three examples to print the output. But you\u2019re still wondering if there is another way to accomplish that task; something compact, aren\u2019t you? Well, I\u2019ve got just the thing you want for situations like this: Associative Arrays.<\/p>\n<p>Associative Arrays are dynamic objects that redefine as per the user&#8217;s needs. These arrays comprise of <strong>key: value<\/strong> pairs where the <strong>key<\/strong> may be an integer or string and the <strong>value<\/strong> can be of any data type. When we assign values to keys in an array variable, the array transforms into an object, losing its properties and methods as Array.<\/p>\n<p>The syntax of creating an associative array is like this:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">var arrayName = {key1: val1, key2: val2, \u2026, keyN: valN};<\/pre>\n<p>I can accomplish my task with associative arrays in the following manner:<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;html&gt;\r\n  &lt;body&gt;\r\n\r\n    &lt;script&gt;\r\n      \/\/creating an associative array\r\n      var associativeArray = {employee: \"Neha\", workingFor:\"DataFlair Web Services\", age: 26, workExperience: 3.5, stillWorking:true};\r\n      \/\/accessing the values of the array\r\n      for (arrayValue in associativeArray){\r\n        document.write(arrayValue + \": \" + associativeArray[arrayValue] + \"&lt;\/br&gt;\");\r\n      }\r\n    &lt;\/script&gt;\r\n\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p><strong>Screenshot:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/associative_array.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-65572\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/associative_array.jpg\" alt=\"associative_array\" width=\"1295\" height=\"740\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/associative_array.jpg 1295w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/associative_array-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/associative_array-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/associative_array-768x439.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/associative_array-1024x585.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/associative_array-520x297.jpg 520w\" sizes=\"auto, (max-width: 1295px) 100vw, 1295px\" \/><\/a><\/p>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/associative_array-op.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"img-gray-border aligncenter wp-image-65573 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/associative_array-op.jpg\" alt=\"associative_array op\" width=\"1296\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/associative_array-op.jpg 1296w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/associative_array-op-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/associative_array-op-300x172.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/associative_array-op-768x439.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/associative_array-op-1024x585.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/associative_array-op-520x297.jpg 520w\" sizes=\"auto, (max-width: 1296px) 100vw, 1296px\" \/><\/a><\/p>\n<p>This was much more effective when working with pairs, don\u2019t you think? But you use the array object when the key is an integer, and when you want access to the special methods and properties of Arrays.<\/p>\n<h3>Accessing JavaScript Array Elements<\/h3>\n<p>You can use the<strong> indexOf()<\/strong> method in <a href=\"https:\/\/en.wikipedia.org\/wiki\/JavaScript\">JavaScript<\/a> to find out the index of a given element in the array. You can also get the value at a specific index.<\/p>\n<p>The code in the console shows an example of each.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/indexof.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"img-gray-border aligncenter wp-image-65574 size-full\" style=\"border: 1px solid #ddd\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/indexof.jpg\" alt=\"indexof\" width=\"1298\" height=\"743\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/indexof.jpg 1298w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/indexof-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/indexof-300x172.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/indexof-768x440.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/indexof-1024x586.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/indexof-520x298.jpg 520w\" sizes=\"auto, (max-width: 1298px) 100vw, 1298px\" \/><\/a><\/p>\n<h3>Add Element in JavaScript Array<\/h3>\n<p>Let\u2019s say I want to add a characteristic of Neha in the above array, nationality: Indian. Use any of the three approaches explained above and add the code in the console.<\/p>\n<h4>1. At the end of an array<\/h4>\n<p>We use the array\u2019s built-in method <strong>push() <\/strong>to add an element at the end of the list.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">array1.push()<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/add-element-at-end-of-array.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"img-gray-border aligncenter wp-image-66188 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/add-element-at-end-of-array.jpg\" alt=\"add-element-at-end-of-array\" width=\"1296\" height=\"740\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/add-element-at-end-of-array.jpg 1296w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/add-element-at-end-of-array-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/add-element-at-end-of-array-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/add-element-at-end-of-array-768x439.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/add-element-at-end-of-array-1024x585.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/add-element-at-end-of-array-520x297.jpg 520w\" sizes=\"auto, (max-width: 1296px) 100vw, 1296px\" \/><\/a><\/p>\n<h4>2. To the front of an array<\/h4>\n<p>We use the array\u2019s built-in method <strong>unshift() <\/strong>to add an element at the front of the list.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">array1.unshift()<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/add-element-at-front-of-array.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"img-gray-border aligncenter wp-image-66189 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/add-element-at-front-of-array.jpg\" alt=\"add-element-at-front-of-array\" width=\"1300\" height=\"740\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/add-element-at-front-of-array.jpg 1300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/add-element-at-front-of-array-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/add-element-at-front-of-array-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/add-element-at-front-of-array-768x437.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/add-element-at-front-of-array-1024x583.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/add-element-at-front-of-array-520x296.jpg 520w\" sizes=\"auto, (max-width: 1300px) 100vw, 1300px\" \/><\/a><\/p>\n<p>We can insert an element in the middle of the array with the help of an array function <strong>splice()<\/strong>. This approach is described under array methods.<\/p>\n<p><em><strong>You must also explore\u00a0<a href=\"https:\/\/data-flair.training\/blogs\/javascript-function\/\">JavaScript Functions<\/a> that will help you further in learning JavaScript easily<\/strong><\/em><\/p>\n<h3>Remove Element from JavaScript Array<\/h3>\n<p>I feel that I don\u2019t really want Neha\u2019s nationality in my records. I will remove it from the array element with the help of simple JavaScript code. Don\u2019t forget, we\u2019re using the console to test our code.<\/p>\n<h4>1. From the end of an array<\/h4>\n<p>We use the array\u2019s built-in method<strong> pop()<\/strong> to remove an element from the end of the list.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">array1.pop()\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/remove-element-from-end-of-array.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"img-gray-border aligncenter wp-image-66190 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/remove-element-from-end-of-array.jpg\" alt=\"remove-element-from-end-of-array\" width=\"1298\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/remove-element-from-end-of-array.jpg 1298w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/remove-element-from-end-of-array-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/remove-element-from-end-of-array-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/remove-element-from-end-of-array-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/remove-element-from-end-of-array-1024x585.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/remove-element-from-end-of-array-520x297.jpg 520w\" sizes=\"auto, (max-width: 1298px) 100vw, 1298px\" \/><\/a><\/p>\n<h4>2. From the front of an array<\/h4>\n<p>We use the array\u2019s built-in method <strong>shift()<\/strong> to remove an element from the front of the list.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">array1.shift()<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/remove-element-from-front-of-array.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"img-gray-border aligncenter wp-image-66191 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/remove-element-from-front-of-array.jpg\" alt=\"remove-element-from-front-of-array\" width=\"1297\" height=\"740\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/remove-element-from-front-of-array.jpg 1297w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/remove-element-from-front-of-array-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/remove-element-from-front-of-array-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/remove-element-from-front-of-array-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/remove-element-from-front-of-array-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/remove-element-from-front-of-array-520x297.jpg 520w\" sizes=\"auto, (max-width: 1297px) 100vw, 1297px\" \/><\/a><\/p>\n<p>You can remove an element at any index position with the help of <strong>splice()<\/strong> method, explained below.<\/p>\n<h3>The Length Property<\/h3>\n<p>This JavaScript property returns the total number of elements present in an array. These update automatically as we modify the array. It doesn\u2019t actually count the values of the array, but the largest numeric index plus 1. This is the reason we cannot access this property with an associative array. The length of an empty array is 0.<\/p>\n<p>An interesting fact to know about the length property is that it\u2019s writable. You can modify it manually; it shows no difference if you increase the length of the array. But, if you decrease the length of the array, it truncates the array i.e. it removes all the values, which aren\u2019t covered in that limit.<\/p>\n<p>The code to find the length of the array is as follows:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">array1.length<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<h3><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/length-property.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"img-gray-border aligncenter wp-image-65581 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/length-property.jpg\" alt=\"length property\" width=\"1296\" height=\"743\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/length-property.jpg 1296w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/length-property-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/length-property-300x172.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/length-property-768x440.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/length-property-1024x587.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/length-property-520x298.jpg 520w\" sizes=\"auto, (max-width: 1296px) 100vw, 1296px\" \/><\/a><\/h3>\n<h3>The splice() method<\/h3>\n<p>You can add\/ remove an array element from any position you want with the help of this JavaScript method. The syntax of a<strong> splice()<\/strong> method looks like this:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">array.splice( start, deleteCount [, \u2026 items ] )<\/pre>\n<p>Insert the element in the array at position 2, without removing 0 elements from the array, with the help of the code:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">array1.splice(2, 0, \u201cIndian\u201d)<\/pre>\n<p>Delete 1 item from the array at position 2 with the help of the following code:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">array1.splice(2, 1)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/splice.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"img-gray-border aligncenter wp-image-65583 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/splice.jpg\" alt=\"splice\" width=\"1298\" height=\"743\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/splice.jpg 1298w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/splice-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/splice-300x172.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/splice-768x440.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/splice-1024x586.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/splice-520x298.jpg 520w\" sizes=\"auto, (max-width: 1298px) 100vw, 1298px\" \/><\/a><\/p>\n<h2>Summary<\/h2>\n<p>Here we conclude our tutorial on JavaScript Array. There are many more methods and properties associated with arrays than we covered, you can test them all when you work with the browser console. All you need to do is create an array and put a dot operator after it. The console will list all the methods associated with that array object, you are free to use any of them whenever needed. But focus on the ones we covered in the tutorial and you\u2019ll learn the other properties and methods as you practice more. Try all the programs mentioned above and experiment with them. <strong><em>For now, you must go through our next <a href=\"https:\/\/data-flair.training\/blogs\/javascript-data-structures\/\">tutorial on JavaScript Data Structures<\/a>.<\/em><\/strong><\/p>\n<p>Hope the article was fruitful for you. Still, if you have any queries feel free to share with us through the comment section below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Earlier in our previous tutorial, we read about JavaScript Event Types. Moving ahead, now we will learn about JavaScript Array. In this article, we will understand what\u00a0are arrays, how to create and work with&#46;&#46;&#46;<\/p>\n","protected":false},"author":7,"featured_media":66565,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18979],"tags":[20781,20673,20672,20779,20780],"class_list":["post-64172","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-add-element-in-javascript-array","tag-create-javascript-array","tag-javascript-array","tag-javascript-array-methods","tag-remove-element-from-javascript-array"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JavaScript Array - A Complete Guide for Beginners! - DataFlair<\/title>\n<meta name=\"description\" content=\"Explore everything about JavaScript Array. Learn how to create &amp; work with array, methods of accessing array and how to add\/ remove &amp; manipulate array.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/javascript-array\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript Array - A Complete Guide for Beginners! - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Explore everything about JavaScript Array. Learn how to create &amp; work with array, methods of accessing array and how to add\/ remove &amp; manipulate array.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/javascript-array\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-08-01T11:44:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-02-17T16:02:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/how-to-create-JavaScript-array.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"801\" \/>\n\t<meta property=\"og:image:height\" content=\"418\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript Array - A Complete Guide for Beginners! - DataFlair","description":"Explore everything about JavaScript Array. Learn how to create & work with array, methods of accessing array and how to add\/ remove & manipulate array.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/javascript-array\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript Array - A Complete Guide for Beginners! - DataFlair","og_description":"Explore everything about JavaScript Array. Learn how to create & work with array, methods of accessing array and how to add\/ remove & manipulate array.","og_url":"https:\/\/data-flair.training\/blogs\/javascript-array\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2019-08-01T11:44:52+00:00","article_modified_time":"2021-02-17T16:02:32+00:00","og_image":[{"width":801,"height":418,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/how-to-create-JavaScript-array.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/javascript-array\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/javascript-array\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/beb0cab24b7aa54423a3b50e669a9dcd"},"headline":"JavaScript Array &#8211; A Complete Guide for Beginners!","datePublished":"2019-08-01T11:44:52+00:00","dateModified":"2021-02-17T16:02:32+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/javascript-array\/"},"wordCount":1423,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/javascript-array\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/how-to-create-JavaScript-array.jpg","keywords":["Add Element in JavaScript Array","Create JavaScript Array","JavaScript Array","JavaScript Array Methods","Remove Element from JavaScript Array"],"articleSection":["JavaScript Tutorial"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/javascript-array\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/javascript-array\/","url":"https:\/\/data-flair.training\/blogs\/javascript-array\/","name":"JavaScript Array - A Complete Guide for Beginners! - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/javascript-array\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/javascript-array\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/how-to-create-JavaScript-array.jpg","datePublished":"2019-08-01T11:44:52+00:00","dateModified":"2021-02-17T16:02:32+00:00","description":"Explore everything about JavaScript Array. Learn how to create & work with array, methods of accessing array and how to add\/ remove & manipulate array.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/javascript-array\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/javascript-array\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/javascript-array\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/how-to-create-JavaScript-array.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/how-to-create-JavaScript-array.jpg","width":801,"height":418,"caption":"how to create JavaScript Array"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/javascript-array\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"JavaScript Tutorial","item":"https:\/\/data-flair.training\/blogs\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"JavaScript Array &#8211; A Complete Guide for Beginners!"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/beb0cab24b7aa54423a3b50e669a9dcd","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c322416204232f4dd97ef3901b0a499a5d34d7ba7fe333f4bfe53a907873d293?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c322416204232f4dd97ef3901b0a499a5d34d7ba7fe333f4bfe53a907873d293?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c322416204232f4dd97ef3901b0a499a5d34d7ba7fe333f4bfe53a907873d293?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team specializes in creating clear, actionable content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Backed by industry expertise, we make learning easy and career-oriented for beginners and pros alike.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam3\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/64172","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=64172"}],"version-history":[{"count":16,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/64172\/revisions"}],"predecessor-version":[{"id":67680,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/64172\/revisions\/67680"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/66565"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=64172"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=64172"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=64172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}