Skip to content

Instantly share code, notes, and snippets.

@Dafrok
Created May 20, 2015 03:22
Show Gist options
  • Select an option

  • Save Dafrok/251a4b67afb74f20bd0a to your computer and use it in GitHub Desktop.

Select an option

Save Dafrok/251a4b67afb74f20bd0a to your computer and use it in GitHub Desktop.
一个计算多维数组深度的奇淫算法
ary=[1,[2,3],[4,[5,6],["7,8"],9],0,[1,2,[3,4,[5,"[6]",[7]],[8],[9]],0],[1,2,3]]
Math.max.apply({},JSON.stringify(ary).replace(/"[^"]*"|[0-9]|,/g,"").replace(/\[\]/g,"[x]").split("x").map(function(str,index,list){str += list.slice(0, index).join('');return str.split('[').length - str.split(']').length}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment