Article 3AP9E Representative Line: An Array of WHY

Representative Line: An Array of WHY

by
Ellis Morning
from The Daily WTF on (#3AP9E)

Labyrinth_1_%28from_Nordisk_familjebok%2

Reader Jeremy sends us this baffling JavaScript: "Nobody on the team knows how it came to be. We think all 'they' wanted was a sequence of numbers starting at 1, but you wouldn't really know that from the code."

var numbers = new Array(maxNumber) .join() .split(',') .map(function(){return ++arguments[1]});

The end result: an array of integers starting at 1 and going up to maxNumber. This is probably the most head-scratchingest way to get that result ever devised.

buildmaster-icon.png [Advertisement] Scale your release pipelines, creating secure, reliable, reusable deployments with one click. Download and learn more today! TheDailyWtf?d=yIl2AUoC8zABKKG-A67zOU
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments