Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jonsequitur committed Jun 8, 2023
1 parent 79aa3d6 commit aec8316
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions docs/javascript-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,50 @@

JavaScript is one of the languages that's supported by default in Polyglot Notebooks. JavaScript is widely used for visualizations in notebooks since the most popular notebook technologies have long been browser-based. While wrapper libraries for plotting and visualization libraries have become very popular, inclusion of JavaScript and the ability to share data easily from other languages makes it an appealing option to write visualization code directly in the original language these libraries.





# FIX ME

## Declaring variables

In JavaScript, variables can be declared in a number of ways, including `let`, `var`, and `const`, or without a keyword.

```javascript
let a = 1;
var b = 2;
const c = 3;
d = 4;
```

The JavaScript kernel executes your code submissions within an async arrow function, and so variables declared within that function's scope aren't visible

outside unless you use this syntax:

```javascript
x = 123;
```

By not using the `let`, `const`, or `var` keywords with your variable declaration, you're enabling JavaScript variable hoisting to make the variable visible to other cells (i.e. within other functions in the top-level scope).

As for return values from JavaScript cells, the trailing expression syntax isn't supported in JavaScript. So while in C# Script, this is equivalent to a `return` statement:

```csharp
123
```

in JavaScript you need to write this:

```javascript
return 123;
```






## Loading dependencies

The first step to using a library is to load it into your notebook session. A couple of approaches are supported today.
Expand Down

0 comments on commit aec8316

Please sign in to comment.