Why is bind slower than a closure?

Chrome 59 update: As I predicted in the answer below bind is no longer slower with the new optimizing compiler. Here’s the code with details: https://codereview.chromium.org/2916063002/ Most of the time it does not matter. Unless you’re creating an application where .bind is the bottleneck I wouldn’t bother. Readability is much more important than sheer performance … Read more

What are the differences between Long Term Support (LTS) and Stable versions of Node.js?

To understand the difference you need to understand why a Long Term Support (LTS) version of Node exists. Node LTS is primarily aimed at enterprise use where there may be more resistance to frequent updates, extensive procurement procedures and lengthy test and quality requirements. From Rod Vagg a member of the Node LTS working group: … Read more

What is the performance of Objects/Arrays in JavaScript? (specifically for Google V8)

I created a test suite, precisely to explore these issues (and more) (archived copy). And in that sense, you can see the performance issues in this 50+ test case tester (it will take a long time). Also as its name suggest, it explores the usage of using the native linked list nature of the DOM … Read more

Dumping whole array: console.log and console.dir output “… NUM more items]”

Setting maxArrayLength There are a few methods all of which require setting maxArrayLength which otherwise defaults to 100. Provide the override as an option to console.dir console.dir(myArry, {‘maxArrayLength’: null}); Set util.inspect.defaultOptions.maxArrayLength = null; which will impact all calls to console.log and util.format Call util.inspect yourself with options. const util = require(‘util’) console.log(util.inspect(array, { maxArrayLength: null … Read more

How to get a microtime in Node.js?

In Node.js, “high resolution time” is made available via process.hrtime. It returns a array with first element the time in seconds, and second element the remaining nanoseconds. To get current time in microseconds, do the following: var hrTime = process.hrtime() console.log(hrTime[0] * 1000000 + hrTime[1] / 1000) (Thanks to itaifrenkel for pointing out an error … Read more

Why is Math.pow() (sometimes) not equal to ** in JavaScript?

99**99 is evaluated at compile time (“constant folding”), and the compiler’s pow routine is different from the runtime one. When evaluating ** at run time, results are identical with Math.pow — no wonder since ** is actually compiled to a Math.pow call: console.log(99**99); // 3.697296376497268e+197 a = 99, b = 99; console.log(a**b); // 3.697296376497263e+197 console.log(Math.pow(99, … Read more