question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JavaScript variables are not being registered outside of cells

See original GitHub issue

Describe the bug

Apologies if this is a misunderstanding of kernel limitations.

I can import a C# variable into JavaScript without issues. However, if I declare a JS variable in a JS cell using either let or const, that variable does not seem to be registered in the variables section, is not available in the next cell (even if it’s a JS cell), does not share correctly to C# or other kernels, and perhaps most interestingly, doesn’t log out at the end of the same cell it was defined in if it was the closing value as in:

let jsVar = 42;
jsVar; // jsVar is not displayed after the cell

JavaScript otherwise appears to function just fine, but variable persistence and sharing just isn’t working for me.

See https://github.com/IntegerMan/PolyglotNotebookTalk/blob/main/cs_js.dib for my sample notebook.

Please complete the following:

Which version of .NET Interactive are you using? (In a notebook, run the #!about magic command. ):

  • OS
    • Windows 11
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Firefox
    • Safari
  • Frontend
    • Jupyter Notebook
    • Jupyter Lab
    • nteract
    • Visual Studio Code
    • Visual Studio Code Insiders
    • Visual Studio
    • Other (please specify)

Screenshots

image

Issue Analytics

  • State:open
  • Created 5 months ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
IntegerMancommented, Apr 20, 2023

I’d also put it in the FAQ as I checked that for this along with the kernels overview before opening the issue.

1reaction
IntegerMancommented, Apr 20, 2023

Thank you so much for the reply @jonsequitur. I’ll play around with that tonight!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Variable not accessible when initialized outside function
It really depends on where your JavaScript code is located. The problem is probably caused by the DOM not being loaded when the...
Read more >
[solved]Why I cant use a variable outside the function ...
you have to declare the variable outside the function to use it. variables declared inside a function can only be accessed inside that...
Read more >
4 Types of Memory Leaks in JavaScript and How to Get Rid ...
In this article we will explore common types of memory leaks in client-side JavaScript code. We will also learn how to use the...
Read more >
var - JavaScript - MDN Web Docs - Mozilla
The var statement declares function-scoped or globally-scoped variables, optionally initializing each to a value.
Read more >
Reactivity in Depth | Vue.js
When you assign or destructure a reactive object's property to a local variable, accessing or assigning to that variable is non-reactive because it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found