ES5 Object.assign equivalent

In underscore.js you can use like, _.extend(firstObj, secondObj); In jQuery, you can use, $.extend({},firstObj,secondObj); In pure javascipt, you can merge n number of objects by using this function: function mergeObjects() { var resObj = {}; for(var i=0; i < arguments.length; i += 1) { var obj = arguments[i], keys = Object.keys(obj); for(var j=0; j < … Read more

type=”text/ecmascript” vs type=”text/javascript”

TL;DR Just omit the type tag, if you don’t care about old browsers. ECMAScript is a language specification standardized by ECMA International as ECMA-262 and ISO/IEC 16262. JavaScript is a programming language that implements this specification. ECMAScript exists in several editions. The latest edition is the 6th (in 2016), but most JavaScript implementations are only … Read more

Why are Octal numeric literals not allowed in strict mode (and what is the workaround?)

Octal literals are not allowed because disallowing them discourages programmers from using leading zeros as padding in a script. For example, look at the following snippet: var eight = 0008, nine = 00009, ten = 000010, eleven = 011; console.log(eight, nine, ten, eleven); Seems harmless enough, right? We programmers with OCD just want to align … Read more

Inconsistent scope of “use strict” on different web browsers (concerning arguments.callee and caller)

Preface A couple of quick points before we get into the meat of this: All modern desktop browsers support use strict… No, not at all. IE8 is a fairly modern browser (not anymore, in 2015), and IE9 is a quite fairly modern browser. Neither of them supports strict mode (IE9 supports parts of it). IE8 … Read more

Which (javascript) environments support ECMAscript 5 strict mode? (aka “use strict”)

Update: See my compatibility table. Original response: None as of now. Raphael Speyer was working on Mozilla implementation for Rhino during this summer, and afaik, their implementation is pretty close to completion. I know (based on info from ES-discuss list) that Microsoft is planning to include some of ES5 features into upcoming versions of IE … Read more

How to force google closure compiler to keep “use strict”; in the compiled js code?

Update: strict mode is now supported in the compiler. Just use –language_in=ECMASCRIPT5_STRICT. References: http://code.google.com/p/closure-compiler/issues/detail?id=69 http://code.google.com/p/closure-compiler/source/detail?r=873 http://code.google.com/p/closure-compiler/source/detail?r=1114

Angular equivalent of jQuery $.map?

Check here: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/map Mozilla has supplied an Array.map polyfill for unsupported browsers if (!Array.prototype.map) { Array.prototype.map = function(callback, thisArg) { var T, A, k; if (this == null) { throw new TypeError(” this is null or not defined”); } // 1. Let O be the result of calling ToObject passing the |this| value as the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)