I have the following code:
function addToPlaylist ({params}) {
debugger
return new Promise((resolve, reject) => {
getPlaylistItems().then((items) => {
if (!items.content) { items.content = [] }
debugger
resolve()
})
})
}
Nevermind what it does, it's just a work in progress and it doesn't really work yet, hence why I'm putting debugger calls in there.
My question: why is params
available at the first breakpoint, but not at the second? I get an 'Uncaught ReferenceError: params is not defined'.
I tried doing params = params
at the beginning because I thought that was a trick which would work, but it doesn't. I tried const _params = params
as well, and it wasn't available inside the then(items) =>
scope either.
What's the deal? I thought Javascript had lexical scoping.
This is happening from a "background script" in a Chrome Extension.