JavaScript
Multi: prototype, functional, eventedThis lab's sandbox. Browsers, Node, and this Code Studio.
This one executes in the sandbox below.
Cheat
- let / const — block scope. var is function scope (avoid).
- === strict equality. == coerces (avoid).
- Array: map, filter, reduce, find, some, every, slice.
- Object: {a: 1}. Access obj.a or obj['a'].
- async: Promise, then, async/await. fetch exists in browsers, not in this sandbox.
- JSON.parse / JSON.stringify for data shapes.
- Template strings: `n=${n}`
Stdlib / core
Math · JSON · Array · String · Number · Date · Object.keys · Map / Set
Pitfalls
- this sandbox has no fetch, no DOM, no require, no parent window.
- Floating point: 0.1 + 0.2 !== 0.3. Use integers for money.
- typeof null === 'object' is a language fossil.
function greet(name) {
return "hello " + name;
}
print(greet("lab"));