Using the "JavaScript" block


#1

The “JavaScript” block makes it possible to write JavaScript inside your Blockly code. This may be useful sometimes. You can find the “JavaScript” block in the category “Control flow -> Other”.

Now you can write JavaScript and have access to the CoSpaces Scripting API.

Please note: The “JavaScript” block does not support TypeScript syntax, only JavaScript.


If you want to declare and define variables in the “JavaScript” block and use these variables in pure Blockly later on you need to omit the var keyword when declaring the variable. This is because of how the generated code is scoped.
So if you want to declare a variable and assign a value to it you should do it like this:

js-block-2

To access this variable in Blockly you first need to create the variable name there in order to use it.


#2

This is also a way to bridge new coders to text based language. :+1:


#3

Please how to run video using Javascript if it is possible in coospaces