In SJS, all variables are references to values.
Syntax rules
var has the same behavior as in JavaScript and is subject to variable hoisting.
const and let are supported and have the same behavior as in JavaScript.
A variable that is assigned a value without being declared becomes a global variable.
A variable declared without an assigned value has a default value of
undefined.
var num = 1;
var str = "hello alipay";
var undef; // undef === undefined
const n = 2;
let s = 'string';
globalVar = 3;Variable names
Naming convention
Variable names must adhere to the following rules:
The first character must be a letter (a-z, A-Z) or an underscore (_).
Subsequent characters can be letters (a-z, A-Z), underscores (_), or numbers (0-9).
Reserved identifiers
Similar to JavaScript, the following identifiers are reserved and cannot be used as variable names:
arguments
break
case
continue
default
delete
do
else
false
for
function
if
Infinity
NaN
null
require
return
switch
this
true
typeof
undefined
var
void
while该文章对您有帮助吗?