blockly > Workspace > getVariable

Workspace.getVariable() method

Find the variable by the given name and return it. Return null if not found.

Signature:

getVariable(name: string, opt_type?: string): VariableModel | null;

Parameters

Parameter Type Description
name string The name to check for.
opt_type string (Optional) The type of the variable. If not provided it defaults to the empty string, which is a specific type.

Returns:

VariableModel | null

The variable with the given name.