Variable

Variable

Variable

Function

variable is used to name the value for subsequent reading, modification and transfer. BT is a dynamically typed language, and variables can be reassigned to different types of values during runtime.

Syntax

Naming rules

RulesDescription
The first charactercan be lowercase English letters, _ or $, and cannot be numbers or uppercase letters.
The following characterscan be English letters, numbers, _ or $.
CaseCase-sensitive, name and Name have different meanings.

Names matching [A-Z][A-Za-z0-9_]* will be recognized as constants, such as Name, Config, NAME, Name_1. If the first letter is capitalized but contains $, such as User$, an error will be reported directly.

let local declaration

let is used to declare local variables within the current function. The uninitialized variable value is empty. let is only a variable and cannot be used to declare constants.

Return Value

TypeDescription
AnyAssignment expression returns the value of the expression on the right.

Code Examples

Notes

  • Multiple statements can be written on new lines or separated by commas.
  • first second third This null declaration initializes the variable to empty.
- Variable names cannot begin with a capital letter; use constant naming rules when non-rewritable bindings are required, and define them directly with assignment syntax.