To date, only a (small) subset of the JavaScript language is supported in Microvium. Basically, Microvium as it stands is meant to be a more-friendly alternative to something like EmbedVM.
Note: the most up-to-date authority on supported features is the set of test scripts, each file of which is a stand-alone Microvium script that exercises a series of features in the language.
- Basic control flow statements (
if
/else
,while
,do..while
,for
) - Primitive operators (
+
,++
,-
,--
,/
,%
,*
,**
,&
,|
,>>
,>>>
,<<
,^
,===
,!==
,>
,<
,>=
,<=
,!
,~
,? :
,typeof
), with the exception that inequality operators (>
,<
,>=
,<=
) only work on numbers at the moment. - Variable declarations:
var
,let
, andconst
- Nested functions (closures) and function/arrow expressions
- Dynamically-sized arrays and objects (with limitations, see the next section), computed properties (
o[p]
). - Function and method calls (
f()
,o.m()
,o[m]()
),this
- Primitive literals and simple globals:
true
/false
,42
,"hello"
,undefined
,null
,NaN
,Infinity
- Object and array literals (
{...}
and[...]
). - Modules, with
import
andexport
statements throw
,try
, andcatch
(but notfinally
)Reflect.ownKeys
(enumerate the keys of an object)Uint8Array
as a lightweight buffer type- Some
class
features: class declarations, constructors and methods. - See also supported builtins
Some notable JavaScript features that are NOT supported in Microvium (some of these may be supported in the future):
void
,delete
, andin
operators.- Option chaining operators like
x?.y
- Nullish coalescing operator
??
- The increment/decrement operators aren't supported on expressions that have computed properties, such as
obj[x]++
. - Class inheritance (
extends
,super
) and computed class members (but you can assign directly to the class prototype if you need to). instanceof
- Class expressions
- Most of the builtin functions and objects. For example, there is no
Array.prototype.map
orUint8Array.prototype.map
. finally
- Iterators and
for..of
for..in
(for object key iteration, useReflect.ownKeys
)- Sloppy equality (
==
,!=
) arguments
,with
- Regular expressions
- BigInt, symbols, WeakMaps
- Destructuring, spread, rest, and default parameters
- Generators, Promises, async/await
require
or dynamicimport
eval
globalThis
Note: any deviation of Microvium from the ECMAScript standard (including unsupported features) is subject to change and should not be relied upon.