TIL Golfing
POSTED ON:
TAGS: coding
Code golf is a type of recreational computer programming competition in which participants strive to achieve the shortest possible source code that implements a certain algorithm. Playing code golf is known as "golf scripting".
The term "code golf" is derived from the similarity of its goal with that of conventional golf, where participants seek to achieve the lowest possible score, rather than the highest, as is the standard in most sports and game scoring systems. While conventional golf players are trying to minimize the number of club strokes needed to complete the course, code golfers are striving to reduce the number of key strokes necessary to write the program.
Example:
a=r[0];b=r[1] // ES5
[a,b]=r // ES6 - 6 bytes saved
Stack Exchange: Golfing in JS
Stack Exchange: Golfing in ECMAScript 6
Related TILs
Tagged: coding