{"id":7613,"date":"2013-01-28T12:16:29","date_gmt":"2013-01-28T12:16:29","guid":{"rendered":"http:\/\/vskills.in\/certification\/tutorial\/?p=7613"},"modified":"2024-04-12T14:17:06","modified_gmt":"2024-04-12T08:47:06","slug":"arrays-object-and-methods","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/arrays-object-and-methods\/","title":{"rendered":"Arrays object and methods"},"content":{"rendered":"<p><strong>Arrays<\/strong> &#8211; It is an ordered collection of values with each value is called an element, having a numeric position in the array called its index. JavaScript arrays may be of any type and elements of the same array can be of different types.<\/p>\n<p><u>Array creation<\/u> &#8211; An array is created with a comma-separated list of elements within square brackets. Array can be empty with no elements or with elements as<\/p>\n<p>var blank = []; \/\/ Empty array<\/p>\n<p>var odd = [1, 3, 5, 7]; \/\/ Array with elements<\/p>\n<p><strong>Array object<\/strong> &#8211; Another way to create an array is with the Array() constructor by calling it with<\/p>\n<ul>\n<li>No arguments: var a = new Array();<\/li>\n<li>A single numeric argument, of length: var a = new Array(10);<\/li>\n<li>Two or more elements: var a = new Array(5, 4, 3, 2, 1, &#8220;testing, testing&#8221;);<\/li>\n<\/ul>\n<p><u>Element access<\/u> &#8211; To access an element of array use the [] operator with array name and index in the square brackets as arrayname[index]. This form can be used to read or write value at the specified index.<\/p>\n<p><strong>Array methods<\/strong> \u2013 Various array methods are discussed below:<\/p>\n<ul>\n<li>concat(array1 [, array2 [, &#8230;]]) &#8211;&nbsp;&nbsp;&nbsp;&nbsp; Creates a new array by joining two or more arrays<\/li>\n<li>filter(callback [, contextObject]) &#8211;&nbsp;&nbsp;&nbsp;&nbsp; Filters the elements of an array using a callback function<\/li>\n<li>join([separator]) &#8211;&nbsp;&nbsp;&nbsp;&nbsp; Join the elements of the array into a string using a separator<\/li>\n<li>pop() &#8211;&nbsp;&nbsp;&nbsp;&nbsp; Removes the last element of the array and returns that element<\/li>\n<li>push(element0 [, element1 [, &#8230;]]) &#8211;&nbsp;&nbsp;&nbsp;&nbsp; Appends one or more elements to the end of the array and returns the new length of the array<\/li>\n<li>reduce(callback [, initialValue]) &#8211;&nbsp;&nbsp;&nbsp;&nbsp; Reduce the array to a single value using a callback function from left-to-right<\/li>\n<li>reverse() &#8211;&nbsp;&nbsp;&nbsp;&nbsp; Reverses the order of the elements in the array<\/li>\n<li>shift() &#8211;&nbsp;&nbsp;&nbsp;&nbsp; Removes the first element of the array and returns that element<\/li>\n<li>slice(offset [, length]) &#8211;&nbsp;&nbsp;&nbsp;&nbsp; Extracts a section of the array and returns a new array containing the extracted elements<\/li>\n<li>sort([compare_function]) &#8211;&nbsp;&nbsp;&nbsp;&nbsp; Sorts the array optionally using a callback function<\/li>\n<li>splice(offset , length [, element1 [, element2 [, &#8230;]]]) &#8211;&nbsp;&nbsp;&nbsp;&nbsp; Replaces elements from the array with something else<\/li>\n<li>toString() &#8211;&nbsp;&nbsp;&nbsp;&nbsp; Returns a string representation of the array<\/li>\n<li>unshift(element0 [, element1 [, &#8230;]]) &#8211;&nbsp;&nbsp;&nbsp;&nbsp; Prepend one or more elements to the front of the array and returns the new length of the array<\/li>\n<li>valueOf() &#8211;&nbsp;&nbsp;&nbsp;&nbsp; Returns the primitive value of the array<\/li>\n<\/ul>\n\n\n<p><a href=\"https:\/\/www.vskills.in\/certification\/tutorial\/dhtml-and-javascript-developer\/\" target=\"_blank\" rel=\"noreferrer noopener\">Back to Tutorial<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Arrays &#8211; It is an ordered collection of values with each value is called an element, having a numeric position in the array called its index. JavaScript arrays may be of any type and elements of the same array can be of different types. Array creation &#8211; An array is created with a comma-separated list&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[3352],"tags":[2814],"class_list":["post-7613","page","type-page","status-publish","hentry","category-dhtml-and-javascript","tag-arrays-object-and-methods"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Arrays object and methods - Tutorial<\/title>\n<meta name=\"description\" content=\"Arrays object and methods. Govt of India Certification for DHTML and Javascript professionals. Get Certified and improve employability. Certification assesses candidates in DHTML.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/arrays-object-and-methods\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Arrays object and methods - Tutorial\" \/>\n<meta property=\"og:description\" content=\"Arrays object and methods. Govt of India Certification for DHTML and Javascript professionals. Get Certified and improve employability. Certification assesses candidates in DHTML.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/arrays-object-and-methods\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T08:47:06+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/arrays-object-and-methods\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/arrays-object-and-methods\/\",\"name\":\"Arrays object and methods - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"datePublished\":\"2013-01-28T12:16:29+00:00\",\"dateModified\":\"2024-04-12T08:47:06+00:00\",\"description\":\"Arrays object and methods. Govt of India Certification for DHTML and Javascript professionals. Get Certified and improve employability. Certification assesses candidates in DHTML.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/arrays-object-and-methods\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/arrays-object-and-methods\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/arrays-object-and-methods\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Arrays object and methods\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Arrays object and methods - Tutorial","description":"Arrays object and methods. Govt of India Certification for DHTML and Javascript professionals. Get Certified and improve employability. Certification assesses candidates in DHTML.","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:\/\/www.vskills.in\/certification\/tutorial\/arrays-object-and-methods\/","og_locale":"en_US","og_type":"article","og_title":"Arrays object and methods - Tutorial","og_description":"Arrays object and methods. Govt of India Certification for DHTML and Javascript professionals. Get Certified and improve employability. Certification assesses candidates in DHTML.","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/arrays-object-and-methods\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T08:47:06+00:00","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/arrays-object-and-methods\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/arrays-object-and-methods\/","name":"Arrays object and methods - Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"datePublished":"2013-01-28T12:16:29+00:00","dateModified":"2024-04-12T08:47:06+00:00","description":"Arrays object and methods. Govt of India Certification for DHTML and Javascript professionals. Get Certified and improve employability. Certification assesses candidates in DHTML.","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/arrays-object-and-methods\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/arrays-object-and-methods\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/arrays-object-and-methods\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Arrays object and methods"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/7613","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=7613"}],"version-history":[{"count":8,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/7613\/revisions"}],"predecessor-version":[{"id":82877,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/7613\/revisions\/82877"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=7613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=7613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=7613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}