ecmascript-5

List of areas missing support for ECMAScript/JavaScript in major browsers?

爷,独闯天下 提交于 2019-12-20 15:32:34
问题 Is anyone aware of a definitive list of areas of missing support for ECMAScript/JavaScript in the major browsers (I'm talking IE7+, Firefox, Chrome, Safari and Opera). Obviously we do feature detection in our code, but I'd like a list of features that we need to perform detection on ideally. 回答1: Some commonly referenced sources are Great compatibility tables at QuirksMode. Some of them are being updated recently. Kangax sums up ES5 support very well. Microsoft released reports of IE

List of areas missing support for ECMAScript/JavaScript in major browsers?

﹥>﹥吖頭↗ 提交于 2019-12-20 15:31:26
问题 Is anyone aware of a definitive list of areas of missing support for ECMAScript/JavaScript in the major browsers (I'm talking IE7+, Firefox, Chrome, Safari and Opera). Obviously we do feature detection in our code, but I'd like a list of features that we need to perform detection on ideally. 回答1: Some commonly referenced sources are Great compatibility tables at QuirksMode. Some of them are being updated recently. Kangax sums up ES5 support very well. Microsoft released reports of IE

ES5 Object.assign equivalent

为君一笑 提交于 2019-12-20 08:49:02
问题 I wanted to do something which is very straight-forward using Object.assign . var firstObj = {name : "Saba H.", rollNo : 1}; var secondObj = {college : "WCE"}; var wholeObj = Object.assign(firstObj, secondObj); console.log(wholeObj); // {name : "Saba H.", rollNo : 1, college : "WCE"} As Object.assign is part of ECMAScript6 harmony proposal and not supported across many browsers, is it possible to do with ES5? If not then is there any micro library? 回答1: In underscore.js you can use like, _

javascript riddle: 2 objects that seem identical with respect to constructor, prototype and __proto__ link, behave differently

∥☆過路亽.° 提交于 2019-12-20 07:26:04
问题 I am an experienced object oriented programmer but this got me! Why am I able to do new f() but not new a(). I will appreciate any pointers. // first a few facts if (Object instanceof Function) console.log("Object isa Function"); console.log("Function.prototype is " + Function.prototype); /* output Object isa Function Function.prototype is function Empty() {} */ var f = new Function(); console.log("Prototype of f:" + f.prototype); console.log("Constructor of f:" + f.constructor); console.log(

How to implement JavaScript/ECMAScript “no LineTerminator here” rule in JavaCC?

这一生的挚爱 提交于 2019-12-20 05:46:33
问题 I continue working on my JavaCC grammar for ECMAScript 5.1. It actually goes quite well, I think I've covered most of the expressions now. I have now two questions, both of them are related to the automatic semicolon insertion (§7.9.1). This is one of them. The specification defines the following production: PostfixExpression : LeftHandSideExpression LeftHandSideExpression [no LineTerminator here] ++ LeftHandSideExpression [no LineTerminator here] -- How can I implement a reliable "no

getPathValue() function for deep objects

℡╲_俬逩灬. 提交于 2019-12-20 05:38:21
问题 This is a follow-up question to this: getPathValue() function for deep objects with arrays and with packed JSON The accepted answer works very well in most situations: function getPathValue(object, path) { return path .replace(/\[/g, '.') .replace(/\]/g, '') .split('.') .reduce(function (o, k) { return (typeof o === 'string' ? JSON.parse(o) : (o || {}))[k]; }, object); } I now have a new requirement. I need it to work with arrays in the root level. For example, this object: [{"currencyPair":

In ECMAScript, how are some of native objects also built-in?

我的未来我决定 提交于 2019-12-20 03:38:24
问题 I suppose a definition of native and built-in objects is required to answer this question. Here's what the ECMAScript spec defines these as: 4.3.6 native object object in an ECMAScript implementation, independent of the host environment, that is present at the start of the execution of an ECMAScript program. NOTE Standard native built-in objects are defined in this specification. Some native objects are built-in ; others may be constructed during the course of execution of an ECMAScript

JS [ES5] How to assign objects with setters and getters?

浪尽此生 提交于 2019-12-20 03:29:14
问题 obj1 = Object.create({}, { property: { enumerable: true, value: 42 } }) > obj1.property = 56 > 56 > obj1.property > 42 with use strict there is an error. I want to combine multiple objects: with jQuery.extend(): new_obj = $.extend(true, objN, obj1) with ES6 Object.assign: new_obj = Object.assign({}, objN, obj1) In any case, the getter turns into a regular property, and therefore it can be changed. How to avoid it? 回答1: You can write your own function that also copies over property attributes:

What is the difference when we use array names instead of spread operator?

江枫思渺然 提交于 2019-12-20 03:23:13
问题 What is the difference if I use: var numbers = [1, 2, 3] var mainArray = (numbers.length > 1) ? numbers : ''; instead of this: var numbers = [1, 2, 3] var mainArray = (numbers.length > 1) ? [...numbers] : ''; 回答1: Since assigment of data structures points to the same space in memory, if you have two variables referencing the same array, altering one variable will alter the other. That is to say: if x = [1, 2, 3] and y = x then we say x.push(5) y will also have that 5 because they are pointing

Why does EcmaScript 5 strict mode go to such great lengths to restrict the identifier `eval`

冷暖自知 提交于 2019-12-20 00:24:51
问题 According to the spec (Annex C), strict-mode code can't do pretty much anything that might assign any identifier with the name eval . I can understand that one might want to restrict use of the actual eval function, but I don't see what purpose is served by restricting use of the name? 回答1: I can only speculate, but it seems to me that ES5-strict is saying that eval and arguments should be considered as raw syntax, not identifiers. It is reasonable that these two features should be