Skip to main content

Javascript cheat sheet

This guide will help you learn Darklang if you're familiar with Javascript.

Have a tip to add to the guide? Submit a PR!


In Javascript, you use a // to start a single line comment, or /* and */ to wrap a multiline comment.:

// This is a comment

/* This is
also a
comment */

In Darklang, you use a let _ = to start a comment, and you write the comment as a String:



In Javascript, you can write a String in multiple ways:

"This is a string"
'This is also a string'

In Darklang, you always use double quotes: from-python/string.png


In Javascript, you use the function keyword to define a function:

function helloWorld(){
return "Hello World";

and you call a function with the function name, followed by parentheses:


In Darklang, you create a function from the sidebar:


This will open a new function in the function space, where you can define the name of the function and its contents:


Standard Library/Built-in Functions

Javascript defines a set of built in functions that are called like this:

// This returns 2 to the power of 2.

Darklang has a set of built in functions as well, which can be accessed via the autocomplete:


If/Else statements

In Javascript, you would write an if statement like this:

var a = 5
var b = 10

if (b > a) {
return "b is greater than a";
else if (a == b) {
return "a and b are equal";
return "a is greater than b";

In Darklang, the same statement would look this this:


Note that we highlight the path your code takes - so if we were to change the values, a different piece of the If statement would be highlighted: