天道酬勤,学无止境

javascript-1.8

解释如何在带有 IndexedDB 的 JavaScript 代码中使用生成器?(Explain how a generator is used in this JavaScript code with IndexedDB?)

问题 在探索 IndexedDB 的美妙世界时,我在 Mozilla 的测试套件中遇到了这样的代码: /** * Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ var testGenerator = testSteps(); function testSteps() { const IDBObjectStore = Components.interfaces.nsIIDBObjectStore; const name = this.window ? window.location.pathname : "Splendid Test"; const description = "My Test Database"; var data = [ { name: "inline key; key generator", autoIncrement: true, storedObject: {name: "Lincoln"}, keyName: "id", keyValue: undefined, }, { name: "inline key; no key generator", autoIncrement: false

2021-07-09 21:00:50    分类:技术分享    javascript   generator   indexeddb   javascript-1.8

Explain how a generator is used in this JavaScript code with IndexedDB?

While making my way through the wonderful world of IndexedDB, I came across code like this from Mozilla's test suite: /** * Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ var testGenerator = testSteps(); function testSteps() { const IDBObjectStore = Components.interfaces.nsIIDBObjectStore; const name = this.window ? window.location.pathname : "Splendid Test"; const description = "My Test Database"; var data = [ { name: "inline key; key generator", autoIncrement: true, storedObject: {name: "Lincoln"}, keyName: "id", keyValue: undefined, }

2021-06-02 11:04:13    分类:问答    javascript   generator   indexeddb   javascript-1.8

Any performance benefit to “locking down” JavaScript objects?

JavaScript 1.8.5 (ECMAScript 5) adds some interesting methods that prevent future modifications of a passed object, with varying degrees of thoroughness: Object.preventExtensions(obj) Object.seal(obj) Object.freeze(obj) Presumably the main point of these is to catch mistakes: if you know that you don't want to modify an object after a certain point, you can lock it down so that an error will be thrown if you inadvertently try to modify it later. (Providing you've done "use strict"; that is.) My question: in modern JS engines such as V8, is there any performance benefit (eg, faster property

2021-04-23 17:11:23    分类:问答    javascript   ecmascript-5   javascript-1.8