javascript-1.8

Any performance benefit to “locking down” JavaScript objects?

假装没事ソ 提交于 2020-04-07 13:46:55
问题 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.)

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

杀马特。学长 韩版系。学妹 提交于 2019-12-04 11:44:30
问题 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

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

允我心安 提交于 2019-12-03 07:21:30
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, }