代码如下: (f =>(x => f(y => x(x)(y)))(x => f(y => x(x)(y))) )(get => node => Array.from(node.childNodes) .filter(node => node.nodeType === Node.ELEMENT_NODE).reduce((depth, node) => Math.max(depth, get(node) + 1), 1) )(document.documentElement)
微博链接: http://weibo.com/1074886493/EodjO45ln?type=comment#_rnd1482937548088
1
hxsf 2016-12-28 23:53:46 +08:00 via iPhone
手机阅读。没啥格式化工具。
目测是遍历 dom 树 返回最大深度 关键字 箭头函数 立即执行函数 |
2
exoticknight 2016-12-29 00:05:47 +08:00
去看看 Y Combinator ,然后应该就懂了……
|
3
xcatliu 2016-12-29 00:37:13 +08:00
不知道把代码写成这样有什么意义
|
4
alexsunxl 2016-12-29 01:13:07 +08:00
作用就跟一楼说那样了, 获得 dom 树最大深度
其实执行一下就知道了, 一般这种就是从右往左边看 附图 |
5
lijsh 2016-12-29 02:29:13 +08:00
美化一下:
(f => (x => f(y => x(x)(y))) (x => f(y => x(x)(y))) ) (get => node => Array.from(node.childNodes) .filter(node => node.nodeType === Node.ELEMENT_NODE) .reduce((depth, node) => Math.max(depth, get(node) + 1), 1) ) (document.documentElement) (f => (x => f(y => x(x)(y))) (x => f(y => x(x)(y))) ) 这种形式是 Y Combinator ,作用是让匿名函数递归自身。 node => Array.from(node.childNodes) .filter(node => node.nodeType === Node.ELEMENT_NODE) .reduce((depth, node) => Math.max(depth, get(node) + 1), 1) 这里就是找 node 的后代元素嵌套深度的,后面把 document.documentElement 传进来。 |
6
lijsh 2016-12-29 02:30:00 +08:00
本想美化一下,没想到排版还是瞎眼…
|
7
yidinghe 2016-12-29 09:23:02 +08:00
试下 markdown
``` function(abc) { alert("Hello!"); } ``` |
8
apoclast 2016-12-29 13:10:05 +08:00
注意力从前端挪走几年了. 现在浏览器支持的 javascript 引擎是什么版本? 什么样的浏览器能支持这种函数式的 js 语法?
|
10
kopp123 2016-12-29 17:00:16 +08:00
这还算鬼畜。这才叫鬼畜
[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]+(!![]+[])[+[]]+(![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]+[+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]])() |
12
mentalidade 2016-12-29 18:14:38 +08:00
@kopp123 可怕,试了下真可以
|
13
KIDJourney 2016-12-29 20:47:40 +08:00 via Android
jsfuck
|
15
palmers 2017-01-02 21:54:14 +08:00
箭头函数没有原函数语法清晰 我觉得
|