Get the promise of error is undefined in IE11

I am converting React code to typescript, target in tsconfig is es5. on running in IE 11 i get an error "Promise is undefined" I know i need to polyfill,but how? I am not using Babel. Following is my Webpack.config var webpack = require("we

Finding the inheritance chain with classes of typescript

We have an inhouse "framework" which builds "classes" for ES5 like this: var MyClass = ourClass({ extends: Base, constructor: function MyClass(...){...} static: {}, ... }) // later somewhere var myClassInstance = new MyClass(...); This

How to best use console.log and console.warn?

I'm working to take over a code base that tests to make sure console.warn exists like this: if (window.console) { console.warn("shhaabang"); } However, my problem with this is that it works only in the browser where you have a window object. Thi

Can Eclipse change the ECMAScript compliance level?

In Eclipse 4.5 (Mars) with installed JavaScript Development Tools (JSDT), the default compliance level for ECMAScript is set to ECMAScript 3, which is already very outdated. And the related drop down list to change the compliance level is deactivated

Set non-writable properties without Object.defineProperty?

So I know you can do this: var obj = {}; Object.defineProperty(obj, 'staticProp', { value: 'I will never change', writable: 'false' }); And I know you can do this: var obj = { get gettableProp(){ return 'gettable!' } } Is there a way to define non-wr

How can I remove functions from the output of the object?

I am learning about the constructor pattern. To exercise what I am learning, I am building an in-memory model called Book inspired by the Mongoose API: var assert = require("assert"); var Book = (function() { var books = []; var constructor = fu

6To5 Compiler - use __proto__ for inheritance

As the output of 6to5 I've got the following code: var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a funct

Data descriptors in literal notation (object creation)

I know that from ECMAScript5 there are two ways of creating objects. 1/ Literal notation which (by default) sets all internal data properties to true (writable, configurable and enumerable. 2/ Using Object.create method which (by default) sets all da

Dynamically set the property of the nested object

I have an object that could be any number of levels deep and could have any existing properties. For example: var obj = { db: { mongodb: { host: 'localhost' } } }; On that I would like to set (or overwrite) properties like so: set('db.mongodb.user',

Confusing the context of the additional ES5 table methods

I try to use some ES5′s array extra methods like map, some, forEach [1, 2, 3].forEach(function (el) { console.log(this) // window }) but I found the context in these methods is not the array which invoke them but the Global context like window. In MD

Why is ~ -1 equal to 0 and ~ 1 equal to -2?

According to subsection 11.4.8 of the ECMAScript 5.1 standard: The production UnaryExpression : ~ UnaryExpression is evaluated as follows: Let expr be the result of evaluating UnaryExpression. Let oldValue be ToInt32(GetValue(expr)). Return the resul

The dangers of crushing JavaScript objects and functions

The nature of JavaScript allows for its native objects to be completely re-written. I want to know if there is any real danger in doing so! Here are some examples of native JavaScript objects Object Function Number String Boolean Math RegExp Array Le

es5-shim and underscore.js?

I have both es5-shim.js and underscore.js in my JavaScript project. es5-shim.js just add some javascript native functions like reduce and some on arrays for Internet Explorer and some old browsers. underscore.js add the same thing (but with a differe

Using shim ES5 with jquery / mootools / prototype

I stumbled across this project: https://github.com/termi/ES5-DOM-SHIM which provides almost full ES5 support in all browsers including old IEs. I've been using it in pure JS projects, but now I have to include jquery/mootools/prototype in a project (

In ECMAScript, how are some native objects also integrated?

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 pres

How to set the class name for the JavaScript object

I have some test class TestKlass = (function() { function TestKlass(value) { this.value = value != null ? value : 'hello world'; console.log(this.value); } return TestKlass; })(); x = new TestKlass; x instanceof TestKlass; (gives true) I have new emp

Idea about the content that passes. Need help

Core Question I need help coming up with a concept to achieve my goal. I am having a problem coming up with an idea to how I can navigate the DOM properly with the method I have chosen. The Goal You should know what I am doing first: I use ajax to ca

Why did ECMAScript 5 add .bind ()?

I just finished reading an article about ECMAScript 5 strict mode. It says that ECMAScript 5 added .bind(). var obj = { method: function(name){ this.name = name; } }; obj.method.bind(obj,"hello"); Isn't it identical to obj.method.call(obj,"

Appropriate non-string Javascript exceptions

Somehow this does not feel like the culmination of the 50 years programming language development: throw "My exception message here"; What's the correct way to do exceptions in Javascript, so that They can be identified (instanceof) They can carr

Is the message property on Error propertyIsEnumerable?

What is the correct result of the following? Do any of the ECMA standards specify this? My current Chrome 14.0.835.186m thinks false and Firefox 3.6.22 thinks true. (new Error()).propertyIsEnumerable("message") This is extra annoying because Chr

Object.prototype JavaScript extension

I am not asking if this is okay: Object.prototype.method = function(){}; This is deemed evil by pretty much everyone, considering it messes up for(var i in obj). The Real Question Ignoring Incompetent browsers(browsers that don't support Object.defin