ecma262

Why is this configurable property not deletable?

喜夏-厌秋 提交于 2019-12-18 04:51:09
问题 Configurable properties seem to be deletable: var o = {}; Object.defineProperty(o, 'prop', { configurable: true, value: 'val' }); delete o.prop; // true o.prop; // undefined But it doesn't work in the following case, at least on Firefox and Chrome: var form = document.createElement('form'), input = document.createElement('input'); form.appendChild(input); var elems = form.elements; Object.getOwnPropertyDescriptor(form, 0) .configurable; // true <────────────────────── !!! delete elems[0]; //

Clarity on the difference between “LexicalEnvironment” and “VariableEnvironment” in ECMAScript/JavaScript

只谈情不闲聊 提交于 2019-12-18 03:43:39
问题 Could someone clarify what the difference is between these two, as they exist in the Execution context? It's hard for me to read the ECMA 262 v 5 specification and clearly see the difference. Thank You, 回答1: Both are components (of the same type) of Execution Contexts, but they serve distinct purposes (from the spec): LexicalEnvironment Identifies the Lexical Environment used to resolve identifier references made by code within this execution context. VariableEnvironment Identifies the

Clarity on the difference between “LexicalEnvironment” and “VariableEnvironment” in ECMAScript/JavaScript

♀尐吖头ヾ 提交于 2019-12-18 03:43:10
问题 Could someone clarify what the difference is between these two, as they exist in the Execution context? It's hard for me to read the ECMA 262 v 5 specification and clearly see the difference. Thank You, 回答1: Both are components (of the same type) of Execution Contexts, but they serve distinct purposes (from the spec): LexicalEnvironment Identifies the Lexical Environment used to resolve identifier references made by code within this execution context. VariableEnvironment Identifies the

How can I rewrite the ErrorMessage for a CustomValidator control on the client?

柔情痞子 提交于 2019-12-17 20:10:08
问题 I have a CustomValidator that is validating a telephone number for several different telephone numbering schemes. The client-side javascript looks like this: validatePhoneNumber(sender, args) { cleanNumber = args.Value.replace(/\D/, ""); country = $("#" + CountryID).get(0).value; switch (country) { case "North America": args.IsValid = validateNAPhoneNumber(cleanNumber); if (!args.IsValid) sender.errormessage = "* Not a NA Phone #"; break; case "UK": args.IsValid = validateUKPhoneNumber

In ECMAScript5, what's the scope of “use strict”?

…衆ロ難τιáo~ 提交于 2019-12-17 15:46:52
问题 What scope does the strict mode pragma have in ECMAScript5? "use strict"; I'd like to do this (mainly because JSLint doesn't complain about it): "use strict"; (function () { // my stuff here... }()); But I'm not sure if that would break other code or not. I know that I can do this, which will scope the pragma to the function... (function () { "use strict"; // my stuff here... }()); but JSLint complains about it (when the "strict" JSLint option is enabled) because it thinks you're executing

Can I disable ECMAscript strict mode for specific functions?

给你一囗甜甜゛ 提交于 2019-12-17 08:34:32
问题 I don't find anything about my question here on MDC or the ECMAscript specifications. Probably somebody knows a more 'hacky' way to solve this. I'm calling "use strict" on every javascript file in my environment. All my files start like this (function(win, doc, undef) { "use strict"; // code & functions }(window, window.document)); Now, I have a custom function which handles errors. That functions uses the .caller property to provide a context stack trace . Looks like this: var chain =

Javascript maximum size for types?

给你一囗甜甜゛ 提交于 2019-12-17 07:48:09
问题 Looking into javascript types I'm trying to find out what the maximum storage size for some data types are. For instance, I set up a quick recursive algo to increase var size till the browser crashes, which ends up being somewhere close to 128mb (or maybe it's 256) for strings on my existing version of chrome. I've been doing it the painful way because I couldn't find any specs on this, but constant browser crashes make this a painful trial (try catch seems useless for some reason with this

Primitive wrapper behavior in JavaScript

只谈情不闲聊 提交于 2019-12-10 21:53:34
问题 In the book Professional Javascript for Web Developers i read that primitive wrappers are used internally by JavaScript when trying to access properties and methods of primitive objects. Does that mean that each time i try to access the length property on a string primitive the value is recalculated? My gut tells me that since strings are fixed then their length value is stored somewhere and only accessed by the wrapper, but i'd rather be sure. 回答1: I think that's true, primitive wrappers are

What is a “calling context?”

别说谁变了你拦得住时间么 提交于 2019-12-10 14:54:20
问题 ECMA-262 5.1 subsections 10.4.2 and 10.4.2.1 refer to a "calling context." This doesn't appear to be described anywhere else in the document. Quoting the spec, emphasis mine: 10.4.2 Entering Eval Code The following steps are performed when control enters the execution context for eval code: If there is no calling context or if the eval code is not being evaluated by a direct call (15.1.2.1.1) to the eval function then, 10.4.2.1 Strict Mode Restrictions The eval code cannot instantiate

JavaScript: Can ECMAScript 5's Strict Mode (“use strict”) be enabled using single quotes ('use strict')?

落爺英雄遲暮 提交于 2019-12-09 14:00:04
问题 JavaScript doesn't care if your Strings are double-quoted "double" or single-quoted 'single' . Every example of ECMAScript 5's strict mode has it enabled by "use strict" in double-quotes. Can I do the following (single-quotes): alert(function(){ 'use strict'; return !this; }()); This will return true if Strict mode is enabled, and false if it is not. 回答1: For you, without using a browser that supports strict mode: A Use Strict Directive is an ExpressionStatement in a Directive Prologue whose