SOURCE

function Folder() {
  return new Proxy({}, {
    get: (target, property) => {
      console.log("Reading" + property)
      
      if(!(property in target)) {
        target[property] = new Folder()
      }
      
      return target[property]
    }
  })
}

const rootFolder = new Folder()

try {
  rooterFolder.ninjasDir.firstNinjaDir.ninjaFile = "Yoshi.text"
  console.log("an exception wasn't raised")
} catch(e) {
  console.log("an exception has occurreed")
}
console 命令行工具 X clear

                    
>
console