Search code examples
javascriptclosuresgoogle-chrome-devtools

How to look JavaScript Internal Property "[[Scopes]]"?


I couldn't find the [[Scopes]] on a function object in the chrome console.

const secureBooking = function () {
  let passengerCount = 0;
  return function () {
    passengerCount++;
    console.log(`${passengerCount} passengers`);
  };
};
const booker = secureBooking();
console.dir(booker);

I am looking for [[Scopes]] property to see closure. But I couldn't find it. I'm sure I've seen it before.

Does anyone know what my issue is?

enter image description here


Solution

  • [[Scopes]] is not an internal JavaScript property, it's a feature created by Chromium debugger. As mentioned in the comments, this feature was removed from the dir tree. The same information is available in Scope tab of the debugger during a breakpoint pause.

    Edit on April 4 2023. [[Scopes]] is re-enabled in Chromium debugger.