codeing or artist ?
记得大学第一节编程课,教授说,"如果一件事儿有对错,那么是科学。如果有美丑好坏,那么是艺术。" 一个能顺利运行还能让人阅读时体验思维美妙的代码,就是艺术和科学的结合。能运行的程序并不是好程序,能当作文章来读的才是。在我看来代码是一种特殊的文体,程序猿其实会写诗。
 1 var obj = {
 2     0:1,
 3     1:2,
 4     2:3,
 5     length:3
 6 };
 7 function toArray(obj){
 8     return Array.prototype.slice.call(obj);
 9 };
10 
11 console.log(toArray(obj));//[1,2,3]

 

posted on 2016-09-01 21:43  codeing-or-artist-??  阅读(144)  评论(0编辑  收藏  举报