{"action":"created","issue":{"url":"https://api.github.com/repos/tc39/proposal-flatMap/issues/68","repository_url":"https://api.github.com/repos/tc39/proposal-flatMap","labels_url":"https://api.github.com/repos/tc39/proposal-flatMap/issues/68/labels{/name}","comments_url":"https://api.github.com/repos/tc39/proposal-flatMap/issues/68/comments","events_url":"https://api.github.com/repos/tc39/proposal-flatMap/issues/68/events","html_url":"https://github.com/tc39/proposal-flatMap/issues/68","id":318812219,"number":68,"title":"Proposal for Array.depth to get depth of an nested array.","user":{"login":"dhunmoon","id":7768142,"avatar_url":"https://avatars0.githubusercontent.com/u/7768142?v=4","gravatar_id":"","url":"https://api.github.com/users/dhunmoon","html_url":"https://github.com/dhunmoon","followers_url":"https://api.github.com/users/dhunmoon/followers","following_url":"https://api.github.com/users/dhunmoon/following{/other_user}","gists_url":"https://api.github.com/users/dhunmoon/gists{/gist_id}","starred_url":"https://api.github.com/users/dhunmoon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhunmoon/subscriptions","organizations_url":"https://api.github.com/users/dhunmoon/orgs","repos_url":"https://api.github.com/users/dhunmoon/repos","events_url":"https://api.github.com/users/dhunmoon/events{/privacy}","received_events_url":"https://api.github.com/users/dhunmoon/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-04-30T08:04:02Z","updated_at":"2018-05-03T12:49:13Z","closed_at":"2018-04-30T08:04:41Z","author_association":"NONE","body":"How about an inbuilt function to find the **depth** of an array, There is already an Experimental feature `Array.prototype.flatten(depth)`  which accepts a **depth** value up to which array needed to be **flatten**\r\nBut there is no inbuilt way to get the **depth** of an array. Currently to get the depth we have to do something like. which is an implicit way to get depth.\r\n```js\r\nfunction depthOf(arr) {\r\n    if(!Array.isArray(arr))\r\n        throw \"Not an Array\"\r\n    var depth = 1;\r\n    var i;\r\n    for(var i = 0; i< arr.length; i++){\r\n        if (!Array.isArray(arr[i])) continue;\r\n\r\n        if(Array.isArray(arr[i])){\r\n            var depth = depthOf(arr[i]) + 1;\r\n            depth = Math.max(depth, depth);\r\n        }\r\n    }\r\n    return depth;\r\n}\r\n```\r\nIf there is option to get **depth** explicitely that would be great. We already have property of array like `Array.length` why not have another property like `Array.depth`.\r\n\r\nAny thoughts."},"comment":{"url":"https://api.github.com/repos/tc39/proposal-flatMap/issues/comments/386284118","html_url":"https://github.com/tc39/proposal-flatMap/issues/68#issuecomment-386284118","issue_url":"https://api.github.com/repos/tc39/proposal-flatMap/issues/68","id":386284118,"user":{"login":"IgnoredAmbience","id":98555,"avatar_url":"https://avatars0.githubusercontent.com/u/98555?v=4","gravatar_id":"","url":"https://api.github.com/users/IgnoredAmbience","html_url":"https://github.com/IgnoredAmbience","followers_url":"https://api.github.com/users/IgnoredAmbience/followers","following_url":"https://api.github.com/users/IgnoredAmbience/following{/other_user}","gists_url":"https://api.github.com/users/IgnoredAmbience/gists{/gist_id}","starred_url":"https://api.github.com/users/IgnoredAmbience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IgnoredAmbience/subscriptions","organizations_url":"https://api.github.com/users/IgnoredAmbience/orgs","repos_url":"https://api.github.com/users/IgnoredAmbience/repos","events_url":"https://api.github.com/users/IgnoredAmbience/events{/privacy}","received_events_url":"https://api.github.com/users/IgnoredAmbience/received_events","type":"User","site_admin":false},"created_at":"2018-05-03T12:49:13Z","updated_at":"2018-05-03T12:49:13Z","author_association":"MEMBER","body":"The array that ljharb gives is self-referential. The given draft algorithm doesn't terminate when given such an array."}}
{"actor":{"display_login":"IgnoredAmbience"}}