Friday 5 April 2013

Convert Array to String in Sencha Touch 2

Today, we are going to see how we can convert array elements into String. Sencha Touch 2 provides join() which will join all the array elements into string using the supplied separator. This function accept separator as the only parameter and returns string.

 var arrayValues = [
  'Sencha Touch Supported Platform:',
  'IOS',
  'Android',
  'Blackberry',
  'Windows Phone 8'
 ];

 var output = arrayValues.join('<br/>');
 console.log(output);

  Output:   
  Sencha Touch Supported Platform:<br/>IOS<br/>Android<br/>Blackberry<br/>Windows Phone 8
 
 Important Note: if separator parameter not supplied, it will use the default seprator ','.

 Hope, you enjoyed this Post.

No comments:

Post a Comment