ajaxjqxhrjquery-ajax

What are the variables [[FunctionLocation]], [[Scopes]]: in the Browser Console


When using jQuery Ajax, in the Browser console I can see the xhr object has two props / fields in some weird notation [double square brackets, don't think it means array in this case];

First, what exactly are they, and second, can I access these values from my JavaScript code?

[[FunctionLocation]]: jquery-3.3.1.min.js:2
[[Scopes]]: Scopes[4]
0: Closure (w.Callbacks) {e: {…}, t: undefined, n: "", r: undefined, i: Array(0), …}
1: Closure {e: Window, r: document, i: ƒ, o: ƒ, a: ƒ, …}
2: Script {loc: Location, baseRestURL: "http://localhost:60123/MyVirtualDir"}
3: Global {parent: Window, opener: null, top: Window, length: 0, frames: Window, …}

enter image description here


Solution

  • No, You can't access them in your code.

    The [[FunctionLocation]] property you see in Inspector is added in V8Debugger::internalProperties() in the debugger's C++ code, which uses another C++ function V8Debugger::functionLocation() to gather information about the function. functionLocation() then uses a number of V8-specific C++ APIs such as v8::Function::GetScriptLineNumber() and GetScriptColumnNumber() to find out the exact information. All APIs described above are exclusively available to C++ code, not JavaScript code. If you are trying to accomplish this task in a platform like Node.js, then you should be able to write a native module. If not, then you are out of luck.

    There is another similar question answered here

    [[Scopes]] is a private property that Chrome developer tools add and use internally, in C++, here in the source. It displays the variables that are in the scope of a function, i.e. which variables can be accessed from that function.