Home arrow JavaScript arrow Page 5 - More on JavaScript Array Objects
JAVASCRIPT

More on JavaScript Array Objects


Thanks for dropping by for another episode of our series on JavaScript Array Objects. We left off discussing five of the thirteen array objects JavaScript has to offer. Here, in this issue, we will make an effort to cover the remaining eight.

Author Info:
By: James Payne
Rating: 5 stars5 stars5 stars5 stars5 stars / 3
December 16, 2008
TABLE OF CONTENTS:
  1. · More on JavaScript Array Objects
  2. · Shift() It Around
  3. · Slice Them Taters
  4. · Sort() It Out
  5. · Fixing the Issue

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
More on JavaScript Array Objects - Fixing the Issue
(Page 5 of 5 )

To fix this issue, we would do the following:


<html>

<body>

<script type="text/javascript">

function sortItOut(a,b)

{

return a - b;

}

var numby = new Array(7);

numby[0] = "100";

numby[1] = "9";

numby[2] = "20";

numby[3] = "25";

numby[4] = "5000";

numby[5] = "40";

numby[6] = "-40";

document.write("Unsorted: ");

document.write(numby + "<br />");

document.write("Sorted: ");

document.write(numby.sort(sortItOut));

</script>

</body>

</html>

It's just that simple folks. As you can see, it even handles negative numbers. The result:

  Unsorted: 100,9,20,25,5000,40,-40
  Sorted: -40,9,20,25,40,100,5000

Well, that isn't all of our Array Objects, but it's all the time we have left for this episode. There are still eight remaining (if we cover our Object Properties, which we most certainly will), so be sure to drop back in for the next installment.

Till then...


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Tutorials for Beginners
- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 3 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials