For the following folder structure, let's say I am viewing documents under "Level 2 Folder", I would like to get ID for "Level 2 Folder" using JavaScript, either using JSCOM or Rest API for SharePoint Online.
-Level 1 Folder --Level 2 Folder ---Level 3 Document
-Level 1 Folder
--Level 2 Folder
---Level 3 Document