我想设置options[Symbol.iterator]属性,以便使用for...of语句迭代我创建的简单对象:
options = {
male: 'John',
female: 'Gina',
rel: 'Love'
};
for(let p of options){
console.log(`Property ${p}`);
};
Run Code Online (Sandbox Code Playgroud)
但是这段代码给了我以下错误:
array.html:72 Uncaught TypeError: options[Symbol.iterator] is not a function
Run Code Online (Sandbox Code Playgroud)
如何在上面的简单对象上设置正确的迭代器函数?
解决了
// define the Iterator for the options object
options[Symbol.iterator] = function(){
// get the properties of the object
let properties = Object.keys(this);
let count = 0;
// set to true when the loop is done
isDone = false;
// define the next method, need for iterator
let …Run Code Online (Sandbox Code Playgroud) 我刚刚安装了firebase-tools和通常的npm软件包安装过程:
npm install -g firebase-tools
Run Code Online (Sandbox Code Playgroud)
我已经创建了一个与Google帐户连接的Firebase帐户,但问题是我可以使用命令行工具进行的唯一程序是:
firebase login // with success
firebase prefs:token // return me the auth token
Run Code Online (Sandbox Code Playgroud)
但每次我尝试其他命令我都会收到错误:
Error: Authentication required.
Run Code Online (Sandbox Code Playgroud)
例如,对于命令init,list等:
firebase init // error
firebase list // error
Run Code Online (Sandbox Code Playgroud)
等等...为什么?
npm,node和firebase-tools的版本:
node : v4.2.2
npm : 3.3.12
firebase : 2.2.0
Run Code Online (Sandbox Code Playgroud) 为什么 Yarn v3.0.2 没有安装包含所有包的 node_modules 文件夹?所以我需要在纱线命令之后运行命令 npm install 吗?每次我使用yarn 3来处理我的依赖项时,我也需要运行npm命令安装吗?
我按照官方GitHub 教程中描述的步骤将Firebase CLI(命令行)与 CI 系统(没有浏览器集成的简单操作系统)一起使用。我使用我的 PC 登录 firebase 并获取令牌(来自浏览器程序)。我在另一个系统上复制了令牌,并在所有命令中传递了令牌,但它不起作用。我收到消息说我需要通过身份验证才能执行这些操作:
firebase login
firebase prefs:token
Run Code Online (Sandbox Code Playgroud)
在其他系统中复制和使用令牌
firebase list --token sdfgfdsg......
Run Code Online (Sandbox Code Playgroud)
有什么问题?
为什么我使用这样的简单线程:
Thread t = new Thread(new Runnable() {
public void run(){
while(true){
.....
idLabel.setText(Date.toString);
Thread.sleep(1000);`
}
t.start();
Run Code Online (Sandbox Code Playgroud)
我有这个错误:
java.lang.IllegalStateException:不在FX应用程序线程上; currentThread = Thread-4
但如果我使用输入文本(如idInputText)而不是标签我没有错误?
我正在使用函数Reflect.ownKeys(Array)处理ECMAScript 6.我得到的属性是:
console.log(Reflect.ownKeys(Array))
["length", "name", "arguments", "caller", "prototype", "isArray", "from", "of", Symbol(Symbol.species)]
Run Code Online (Sandbox Code Playgroud)
但我仍然可以在阵列上使用forEach方法!但是我无法找到定义函数forEach的位置,例如属性!
firebase ×2
javascript ×2
arrays ×1
debugging ×1
ecmascript-6 ×1
for-of-loop ×1
iterator ×1
java ×1
javafx-2 ×1
yarnpkg ×1