const
declarations for variables that are never reassigned JS-0242117 let rawdata = fs.readFileSync(jsonFile);
118 let person = JSON.parse(rawdata);
119 console.log(person.START_JUMP)
120 let client = Client.createClient(ALIYUN.ACCESS_KEY, ALIYUN.ACCESS_KEY_SECRET);121 await Client.BatchPubSample(client, ALIYUN.PRODUCT_KEY, ALIYUN.IOT_INSTANCE_ID, base64encode(JSON.stringify(person.START_JUMP)), topic, sn);
122 }
123}
115 const topic = "get";
116 const sn = ALIYUN.DEVICE_NAME;
117 let rawdata = fs.readFileSync(jsonFile);
118 let person = JSON.parse(rawdata);119 console.log(person.START_JUMP)
120 let client = Client.createClient(ALIYUN.ACCESS_KEY, ALIYUN.ACCESS_KEY_SECRET);
121 await Client.BatchPubSample(client, ALIYUN.PRODUCT_KEY, ALIYUN.IOT_INSTANCE_ID, base64encode(JSON.stringify(person.START_JUMP)), topic, sn);
114 static async publishJumpingOrder() {
115 const topic = "get";
116 const sn = ALIYUN.DEVICE_NAME;
117 let rawdata = fs.readFileSync(jsonFile);118 let person = JSON.parse(rawdata);
119 console.log(person.START_JUMP)
120 let client = Client.createClient(ALIYUN.ACCESS_KEY, ALIYUN.ACCESS_KEY_SECRET);
106 let rawdata = fs.readFileSync(jsonFile);
107 let person = JSON.parse(rawdata);
108 console.log(person.GROUPING)
109 let client = Client.createClient(ALIYUN.ACCESS_KEY, ALIYUN.ACCESS_KEY_SECRET);110 await Client.BatchPubSample(client, ALIYUN.PRODUCT_KEY, ALIYUN.IOT_INSTANCE_ID, base64encode(JSON.stringify(person.GROUPING)), topic, sn);
111 }
112
104 const topic = "get";
105 const sn = ALIYUN.DEVICE_NAME;
106 let rawdata = fs.readFileSync(jsonFile);
107 let person = JSON.parse(rawdata);108 console.log(person.GROUPING)
109 let client = Client.createClient(ALIYUN.ACCESS_KEY, ALIYUN.ACCESS_KEY_SECRET);
110 await Client.BatchPubSample(client, ALIYUN.PRODUCT_KEY, ALIYUN.IOT_INSTANCE_ID, base64encode(JSON.stringify(person.GROUPING)), topic, sn);
Variables that are never re-assigned a new value after their initial declaration should be declared with the const
keyword.
This prevents the programmer from erroneously re-assigning to a read-only variable, and informs those reading the code that a variable is a constant value.
let pi = Math.PI
for (let x of xs) {
use(x);
}
let { a, b } = object;
use(a, b);
const pi = Math.PI
for (const x of xs) {
use(x);
}
const { a, b } = object;
use(a, b);