<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>array-function &#8211; MaxVergelli.com</title>
	<atom:link href="https://www.maxvergelli.com/tag/array-function/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.maxvergelli.com</link>
	<description>sourcecode repository</description>
	<lastBuildDate>Tue, 07 Apr 2020 13:42:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://i2.wp.com/www.maxvergelli.com/wp-content/uploads/2020/04/wp-1586823685141.png?fit=32%2C32&#038;ssl=1</url>
	<title>array-function &#8211; MaxVergelli.com</title>
	<link>https://www.maxvergelli.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">34603511</site>	<item>
		<title>How to export an ASP Associative Array to XML</title>
		<link>https://www.maxvergelli.com/how-to-export-an-asp-associative-array-to-xml/</link>
					<comments>https://www.maxvergelli.com/how-to-export-an-asp-associative-array-to-xml/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Sat, 15 Feb 2020 16:27:57 +0000</pubDate>
				<category><![CDATA[Classic ASP]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MS Access]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[array-function]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[asp-associative-array]]></category>
		<category><![CDATA[associative-array]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[data-layer]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[datetime-conversion]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[enumerating]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[helper-class]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[string-conversion]]></category>
		<category><![CDATA[string-manipulation]]></category>
		<category><![CDATA[wrapper-class]]></category>
		<category><![CDATA[xml]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=82</guid>

					<description><![CDATA[&#8220;Asp Associative Array Class&#8221; provides a method to easly export all items to a well formatted XML string. For example, You can create a new *.ASP file : [sourcecode language=&#8221;vb&#8221;] &#60;!&#8211;#include file=&#34;AssociativeArrayClass.asp&#34; &#8211;&#62; &#60;% Dim Person, God Set Person = &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/how-to-export-an-asp-associative-array-to-xml/" aria-label="How to export an ASP Associative Array to XML">Read More</a>]]></description>
										<content:encoded><![CDATA[<p><a href="https://sourceforge.net/projects/asp-assoc-array/files/ASP_Associative_Array.rar/download" target="_blank" rel="noopener noreferrer">&#8220;Asp Associative Array Class&#8221;</a> provides a method to easly export all items to a well formatted XML string. For example, You can create a new *.ASP file :</p>
[sourcecode language=&#8221;vb&#8221;]
&lt;!&#8211;#include file=&quot;AssociativeArrayClass.asp&quot; &#8211;&gt;<br />
&lt;%<br />
Dim Person, God<br />
Set Person = New AssociativeArray<br />
Set God = New AssociativeArray<br />
Person(&quot;name&quot;) = &quot;Max&quot;<br />
Person(&quot;surname&quot;) = &quot;Vergelli&quot;<br />
God(&quot;name&quot;) = &quot;Jesus&quot;<br />
God(&quot;surname&quot;) = &quot;Christ&quot;<br />
Dim World<br />
Set World = New AssociativeArray<br />
World(1) = Person<br />
World(2) = God<br />
response.Write World.ToXML()<br />
%&gt;<br />
[/sourcecode]
<p>And You will get out the following XML:</p>
[sourcecode language=&#8221;xml&#8221;]
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br />
&lt;array&gt;<br />
      &lt;key&gt;<br />
            &lt;name&gt;&lt;![CDATA[1]]&gt;&lt;/name&gt;<br />
            &lt;value&gt;<br />
                    &lt;key&gt;<br />
                           &lt;name&gt;&lt;![CDATA[name]]&gt;&lt;/name&gt;<br />
                           &lt;value&gt;&lt;![CDATA[Max]]&gt;&lt;/value&gt;<br />
                    &lt;/key&gt;<br />
                    &lt;key&gt;<br />
                           &lt;name&gt;&lt;![CDATA[surname]]&gt;&lt;/name&gt;<br />
                           &lt;value&gt;&lt;![CDATA[Vergelli]]&gt;&lt;/value&gt;<br />
                   &lt;/key&gt;<br />
           &lt;/value&gt;<br />
      &lt;/key&gt;<br />
      &lt;key&gt;<br />
             &lt;name&gt;&lt;![CDATA[2]]&gt;&lt;/name&gt;<br />
             &lt;value&gt;<br />
                    &lt;key&gt;<br />
                           &lt;name&gt;&lt;![CDATA[name]]&gt;&lt;/name&gt;<br />
                           &lt;value&gt;&lt;![CDATA[Jesus]]&gt;&lt;/value&gt;<br />
                    &lt;/key&gt;<br />
                    &lt;key&gt;<br />
                          &lt;name&gt;&lt;![CDATA[surname]]&gt;&lt;/name&gt;<br />
                          &lt;value&gt;&lt;![CDATA[Christ]]&gt;&lt;/value&gt;<br />
                    &lt;/key&gt;<br />
             &lt;/value&gt;<br />
       &lt;/key&gt;<br />
&lt;/array&gt;<br />
[/sourcecode]
]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/how-to-export-an-asp-associative-array-to-xml/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">82</post-id>	</item>
		<item>
		<title>How to populate an ASP Associative Array with records from MySQL / Access database Table</title>
		<link>https://www.maxvergelli.com/how-to-populate-an-asp-associative-array-with-records-from-mysql-access-database-table/</link>
					<comments>https://www.maxvergelli.com/how-to-populate-an-asp-associative-array-with-records-from-mysql-access-database-table/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Sat, 08 Feb 2020 16:17:39 +0000</pubDate>
				<category><![CDATA[Classic ASP]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MS Access]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[array-function]]></category>
		<category><![CDATA[asp-associative-array]]></category>
		<category><![CDATA[associative-array]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[data-layer]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[dataset]]></category>
		<category><![CDATA[enumerating]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[helper-class]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[string-manipulation]]></category>
		<category><![CDATA[wrapper-class]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=80</guid>

					<description><![CDATA[In this example, You can learn how to populate an ASP Associative Array with the records of a database table (MS Access or MySQL); then, how to programmatically manage well structured data without any extra SQL. Before to start: For &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/how-to-populate-an-asp-associative-array-with-records-from-mysql-access-database-table/" aria-label="How to populate an ASP Associative Array with records from MySQL / Access database Table">Read More</a>]]></description>
										<content:encoded><![CDATA[<p>In this example, You can learn how to populate an ASP Associative Array with the records of a database table (MS Access or MySQL); then, how to programmatically manage well structured data without any extra SQL.</p>
<p><strong>Before to start:<br />
</strong>For this tutorial, You need to download this <a href="https://sourceforge.net/projects/asp-assoc-array/files/myDatabase_Example_for_Tutorial.mdb/download" target="_blank" rel="noopener noreferrer">MS Access database</a> example or You can create a new one in MySQL executing this SQL:</p>
[sourcecode language=&#8221;sql&#8221;]
CREATE TABLE `myTable` (<br />
`myField1` INT( 11 ) NOT NULL ,<br />
`myField2` VARCHAR( 255 ) NULL DEFAULT &#8216;test&#8217;,<br />
`myField3` VARCHAR( 255 ) NULL DEFAULT &#8216;test&#8217;,<br />
PRIMARY KEY ( `myField1` )<br />
) TYPE = MYISAM ;<br />
INSERT INTO `myTable` (`myField1`, `myField2`, `myField3`)<br />
 VALUES(1, &#8216;rec1 Text2&#8217;, &#8216;rec1 Text3&#8217;);<br />
INSERT INTO `myTable` (`myField1`, `myField2`, `myField3`)<br />
 VALUES(2, &#8216;rec2 Text2&#8217;, &#8216;rec2 Text3&#8217;);<br />
INSERT INTO `myTable` (`myField1`, `myField2`, `myField3`)<br />
 VALUES(3, &#8216;rec3 Text2&#8217;, &#8216;rec3 Text3&#8217;);<br />
[/sourcecode]
<p>Besides, to create an &#8220;AssociativeArray&#8221; object, You need to include the <a href="https://sourceforge.net/projects/asp-assoc-array/files/ASP_Associative_Array.rar/download" target="_blank" rel="noopener noreferrer">&#8220;ASP Associative Array Class&#8221;</a> file in your asp page with an include statement:</p>
[sourcecode language=&#8221;vb&#8221;]
&lt;!&#8211;#include file=&quot;AssociativeArrayClass.asp&quot; &#8211;&gt;<br />
[/sourcecode]
<p><strong>Tutorial:</strong><br />
The target is to grab data from a database Table and save records in an Associative Array, then You need to create a Database connection by ADODB&#8230;</p>
[sourcecode language=&#8221;vb&#8221;]Set DbConnection = Server.CreateObject(&quot;ADODB.Connection&quot;)[/sourcecode]
<p>Select a Provider for MS Access or MySQL:</p>
[sourcecode language=&#8221;vb&#8221;]dbConnectionString = _<br />
   &quot;driver={Microsoft Access Driver (*.mdb)}; DBQ=&quot; &amp; _<br />
           Server.MapPath(&quot;myDatabase.mdb&quot;)[/sourcecode]
<p>For MySQL Databases You can also use a connection string like the following:</p>
[sourcecode language=&#8221;vb&#8221;]&quot;driver={MySQL ODBC 3.51 Driver}; Server=; Uid=; Pwd=; Database=;&quot;[/sourcecode]
<p>Open a database connection and create a SQL Select:</p>
[sourcecode language=&#8221;vb&#8221;]DbConnection.Open dbConnectionString<br />
Dim sql : sql = &quot;SELECT * FROM myTable&quot;[/sourcecode]
<p>Create and Populate the Associative Array with selected Records and close database connection:</p>
[sourcecode language=&#8221;vb&#8221;]Dim Table<br />
Set Table = New AssociativeArray<br />
Table.Fill DbConnection, sql<br />
Set DbConnection = Nothing[/sourcecode]
<p><strong>Manage Records inside the Associative Array:</strong><br />
Right now, You can manage each record (and its values) inside the Associative Array. For example, You could get the first Record and its Values in each Field:</p>
[sourcecode language=&#8221;vb&#8221;]Response.Write( _<br />
                Table(0)(&quot;myField1&quot;) &amp; &quot; , &quot; &amp; _<br />
                Table(0)(&quot;myField2&quot;) &amp; &quot; , &quot; &amp; _<br />
                Table(0)(&quot;myField3&quot;) &amp; &quot;&lt;br /&gt;&quot;)[/sourcecode]
<p>the following code gets the second Record and its Values in each Field:</p>
[sourcecode language=&#8221;vb&#8221;]Response.Write( _<br />
                Table(1)(&quot;myField1&quot;) &amp; &quot; , &quot; &amp; _<br />
                Table(1)(&quot;myField2&quot;) &amp; &quot; , &quot; &amp; _<br />
                Table(1)(&quot;myField3&quot;) &amp; &quot;&lt;br /&gt;&quot;)[/sourcecode]
<p>it gets the total Records Count</p>
[sourcecode language=&#8221;vb&#8221;]Response.Write(&quot;&lt;p&gt;Total Records: &quot; &amp; Table.Count &amp; &quot;&lt;/p&gt;&quot;)[/sourcecode]
<p>this enumerates all Records inside the Associative Array:</p>
[sourcecode language=&#8221;vb&#8221;]Response.Write(&quot;&lt;ul&gt;&quot;)<br />
For Each row In Table.Items<br />
   Dim record<br />
   Set record = row.Value &#8216;get current Record Object<br />
   Response.Write(&quot;&lt;li&gt;&quot; &amp; record(&quot;myField1&quot;) &amp; &quot; : &quot; &amp; _<br />
                           record(&quot;myField2&quot;) &amp; &quot; : &quot; &amp; _<br />
                           record(&quot;myField3&quot;) &amp; &quot;&lt;/li&gt;&quot;)<br />
Next<br />
Response.Write(&quot;&lt;/ul&gt;&quot;)[/sourcecode]
<p>and finally it gets all records by index (zero-based):</p>
[sourcecode language=&#8221;vb&#8221;]Response.Write(&quot;&lt;ul&gt;&quot;)<br />
For n = 0 To Table.Count &#8211; 1<br />
     Response.Write(&quot;&lt;li&gt;&quot; &amp; Table(n)(&quot;myField1&quot;) &amp; &quot; : &quot; &amp; _<br />
                             Table(n)(&quot;myField2&quot;) &amp; &quot; : &quot; &amp; _<br />
                             Table(n)(&quot;myField3&quot;) &amp; &quot;&lt;/li&gt;&quot;)<br />
Next<br />
Response.Write(&quot;&lt;/ul&gt;&quot;)[/sourcecode]
<p>That&#8217;s all,<br />
Get the full example at <a href="http://sourceforge.net/projects/asp-assoc-array/">http://sourceforge.net/projects/asp-assoc-array/</a></p>
<p>Max</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/how-to-populate-an-asp-associative-array-with-records-from-mysql-access-database-table/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">80</post-id>	</item>
		<item>
		<title>How to use Associative Arrays in ASP</title>
		<link>https://www.maxvergelli.com/how-to-use-associative-arrays-in-asp/</link>
					<comments>https://www.maxvergelli.com/how-to-use-associative-arrays-in-asp/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Sat, 01 Feb 2020 16:03:13 +0000</pubDate>
				<category><![CDATA[Classic ASP]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MS Access]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[array-function]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[asp-associative-array]]></category>
		<category><![CDATA[associative-array]]></category>
		<category><![CDATA[classic-asp]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[data-layer]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[datetime-conversion]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[enumerating]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[helper-class]]></category>
		<category><![CDATA[isarray-function]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[string-conversion]]></category>
		<category><![CDATA[string-manipulation]]></category>
		<category><![CDATA[vbscript]]></category>
		<category><![CDATA[wrapper-class]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=78</guid>

					<description><![CDATA[First of all, You need to download the &#8220;Asp Associative Array class&#8221; then include the file &#8220;AssociativeArrayClass.asp&#8221; in your asp page. Right now, You can start declaring associative arrays in ASP with the following syntax: [sourcecode language=&#8221;vb&#8221;] Dim Person Set &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/how-to-use-associative-arrays-in-asp/" aria-label="How to use Associative Arrays in ASP">Read More</a>]]></description>
										<content:encoded><![CDATA[<p>First of all, You need to download the <a href="http://sourceforge.net/projects/asp-assoc-array/">&#8220;Asp Associative Array class&#8221;</a> then include the file &#8220;AssociativeArrayClass.asp&#8221; in your asp page.</p>
<p>Right now, You can start declaring associative arrays in ASP with the following syntax:</p>
[sourcecode language=&#8221;vb&#8221;]
Dim Person<br />
Set Person = New AssociativeArray<br />
Person(&quot;name&quot;)    =   &quot;Max&quot;<br />
Person(&quot;surname&quot;) =   &quot;Vergelli&quot;<br />
Response.Write Person(&quot;name&quot;) &amp; &quot; &quot; &amp; Person(&quot;surname&quot;)<br />
[/sourcecode]
<p>In the above example, the key &#8220;name&#8221; in &#8220;Person&#8221; object, stores &#8220;Max&#8221; value. You can set strings or integers for the key and <strong>any object/variant type for the relative value</strong>. However, You can not set key with Null or &#8220;&#8221; strings like the following:</p>
[sourcecode language=&#8221;vb&#8221;]
&#8216;invalid keys&#8230;<br />
Person(Null) = &quot;Null Key&quot;<br />
Person(&quot;&quot;) = &quot;Empty String&quot;<br />
Dim undefined<br />
Person(undefined) = &quot;Variable Not Initialized&quot;<br />
Response.Write Person(&quot;&quot;) &amp; Person(Null) &amp; Person(undefined)<br />
[/sourcecode]
<p><strong>How to get every item of the associative array:</strong><br />
You can make a &#8220;For Each&#8221; loop on the array like in the following code</p>
[sourcecode language=&#8221;vb&#8221;]
For Each element In Person.Items<br />
   Response.Write element.Key &amp; &quot; : &quot; &amp; element.Value &amp; vbCrLf<br />
Next<br />
[/sourcecode]
<p>&#8220;Person.Items&#8221; gets all the items inside the associative array and for each item You can get &#8220;Key&#8221; and &#8220;Value&#8221; properties.</p>
<p><strong>How to copy an associative array:</strong></p>
[sourcecode language=&#8221;vb&#8221;]
Dim Person_Clone             &#8216;it&#8217;s a Variant type<br />
Set Person_Clone = Person    &#8216;NOTE: Use &quot;Set&quot; statement!<br />
&#8216;print values<br />
Response.Write Person_Clone(&quot;name&quot;) &amp; &quot; &quot; &amp; Person_Clone(&quot;surname&quot;) &amp; vbCrLf<br />
&#8216;get each key/value<br />
For Each element In Person_Clone.Items<br />
   Response.Write element.Key &amp; &quot; : &quot; &amp; element.Value &amp; vbCrLf<br />
Next<br />
[/sourcecode]
<p><strong>How to create nested associative arrays&#8230;</strong><br />
You can create infinite nested associative arrays and accessing them like the following:</p>
[sourcecode language=&#8221;vb&#8221;]
Dim Person<br />
Set Person = New AssociativeArray<br />
Person(&quot;name&quot;) = &quot;Max&quot;<br />
Person(&quot;surname&quot;) = &quot;Vergelli&quot;<br />
Dim People<br />
Set People = New AssociativeArray<br />
People(1) = Person<br />
People(2) = Person<br />
People(3) = Person<br />
Response.Write People(1)(&quot;name&quot;) &amp; &quot; &quot; &amp; People(1)(&quot;surname&quot;)<br />
[/sourcecode]
<p>Besides, You can enumerate all the keys/values inside the &#8220;People&#8221; associative array object</p>
[sourcecode language=&#8221;vb&#8221;]
For Each element In People.Items<br />
   Dim el_person<br />
   Set el_person = element.Value<br />
   Response.Write el_person(&quot;name&quot;) &amp; &quot; : &quot; &amp; el_person(&quot;surname&quot;) &amp; vbCrLf<br />
Next<br />
[/sourcecode]
]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/how-to-use-associative-arrays-in-asp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">78</post-id>	</item>
		<item>
		<title>Javascript isArray() function</title>
		<link>https://www.maxvergelli.com/javascript-isarray-function/</link>
					<comments>https://www.maxvergelli.com/javascript-isarray-function/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Fri, 01 Nov 2019 14:50:42 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[array-function]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[datatype]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[isarray-function]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[string-manipulation]]></category>
		<category><![CDATA[typeof]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=55</guid>

					<description><![CDATA[Javascript does not provide a function to recognize if a variable is an array or not; you can make a &#8220;typeof&#8221; of the variable however u&#8217;ll get an &#8216;object&#8217; datatype, as in the following code [sourcecode language=&#8221;javascript&#8221;] var myarray = &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/javascript-isarray-function/" aria-label="Javascript isArray() function">Read More</a>]]></description>
										<content:encoded><![CDATA[<p>Javascript does not provide a function to recognize if a variable is an array or not; you can make a &#8220;typeof&#8221; of the variable however u&#8217;ll get an &#8216;object&#8217; datatype, as in the following code<br />
[sourcecode language=&#8221;javascript&#8221;]
var myarray = [1, 2, 3];<br />
var myobject = { key: &#8216;value&#8217; };<br />
alert(typeof myarray); //return &#8216;object&#8217;<br />
alert(typeof myobject); //return &#8216;object&#8217;<br />
[/sourcecode]
<p>to recognize a data type &#8216;object&#8217; from &#8216;array&#8217;, you need a specialized function like this&#8230;<br />
[sourcecode language=&#8221;javascript&#8221;]
function isArray(value){<br />
	var b = typeof value;<br />
	if(b === &#8216;object&#8217;){<br />
		if(value){<br />
			b = (typeof value.length === &#8216;number&#8217; &amp;&amp;<br />
				!(value.propertyIsEnumerable(&#8216;length&#8217;)) &amp;&amp;<br />
				typeof value.splice === &#8216;function&#8217;) ? true : false;<br />
		}else{<br />
			b = false;<br />
		};<br />
	};<br />
	return b;<br />
};<br />
var myarray = [1, 2, 3];<br />
var myobject = { key: &#8216;value&#8217; };<br />
alert(isArray(myarray)); //return true<br />
alert(isArray(myobject)); //return false<br />
[/sourcecode]
<p>Good work!<br />
Max 🙂</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/javascript-isarray-function/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">55</post-id>	</item>
	</channel>
</rss>
