Expected property shorthand
77 // 指定消息的发送方式,支持QoS0和QoS1
78 qos: 0,
79 //自定义Topic的后缀
80 topicShortName: topicShortName, 81 deviceName: [
82 deviceName
83 ],
Expected property shorthand
73 // 产品ProductKey
74 productKey: productKey,
75 // 要发送的消息主体,hello world Base64 String
76 messageContent: messageContent, 77 // 指定消息的发送方式,支持QoS0和QoS1
78 qos: 0,
79 //自定义Topic的后缀
Expected property shorthand
71 // 物联网平台实例ID
72 iotInstanceId: iotInstanceId,
73 // 产品ProductKey
74 productKey: productKey, 75 // 要发送的消息主体,hello world Base64 String
76 messageContent: messageContent,
77 // 指定消息的发送方式,支持QoS0和QoS1
Expected method shorthand
1"use strict";
2var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3 if (k2 === undefined) k2 = k;
4 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 5}) : (function(o, m, k, k2) {
6 if (k2 === undefined) k2 = k;
7 o[k2] = m[k];
Expected property shorthand
69 try {
70 let request = new $Iot.BatchPubRequest({
71 // 物联网平台实例ID
72 iotInstanceId: iotInstanceId, 73 // 产品ProductKey
74 productKey: productKey,
75 // 要发送的消息主体,hello world Base64 String
Description
ECMAScript 6 provides a concise form for defining object literal methods and properties. This syntax can make defining complex object literals much cleaner.
Here are a few common examples using the ES5 syntax:
const x = 1, y = 2, z = 3;
// properties
const foo = {
x: x,
y: y,
z: z,
};
// methods
const foo = {
a: function() {},
b: function() {}
};
The ES6 equivalent syntax is::
// properties
const foo = {x, y, z};
// methods
const bar = {
a() { return 1 },
b() { return 2 }
};
NOTE: The shorthand properties are equivalent to function expressions.
Meaning that they do not bind their own this
inside their bodies.
It is still possible to access properties from the object inside a shorthand member function:
const object = {
x: 1,
getX() {
return this.x // valid
}
}
Bad Practice
const foo = {
bar: function () { return 1 }
};
Recommended
const foo = {
bar() { return 1 }
}