当使用对象循环时,const
Bixbylet
胶囊本地端点 javascript 上的关键字出现故障。
我在笔记本电脑(Ubuntu 18.04)上运行 Bixby 工作室。尝试 Bixby 模拟器,调试控制台 api 结果以意想不到的方式构造。
var http = require('http')
var console = require('console')
var config = require('config')
module.exports.function = function getBTCRates () {
console.log("GET /ticker without any parameter!)")
// Read the remote.url value from capsule.properties
var response = http.getUrl(config.get('blockchain.url') + '/ticker', { format: 'json' });
var items = [];
for (var currency in response) {
var item = response[currency];
item.quarterBefore = item['15m']
delete item['15m'];
item.currency = currency;
items.push(item)
}
return items;
}
如果我将var
关键字更改为const
或let
如下,它会发生故障。
var http = require('http')
var console = require('console')
var config = require('config')
module.exports.function = function getBTCRates () {
console.log("GET /ticker without any parameter!)")
// Read the remote.url value from capsule.properties
var response = http.getUrl(config.get('blockchain.url') + '/ticker', { format: 'json' });
const items = [];
for (let currency in response) {
const item = response[currency];
item.quarterBefore = item['15m']
delete item['15m'];
item.currency = currency;
items.push(item)
}
return items;
}
当我使用const
,let
关键字时,结果如下:
当我使用var
关键字时,结果如下: