Skip to main content
Commonmark migration
Source Link

##Most of the time it does not matter.

Most of the time it does not matter.

##However yes, when it matters - .bind is slower

However yes, when it matters - .bind is slower

###First, let's look at the bind algorithm defined in the specification:

First, let's look at the bind algorithm defined in the specification:

  1. Let Target be the this value.
  2. If IsCallable(Target) is false, throw a TypeError exception.
  3. Let A be a new (possibly empty) internal list of all of the argument values provided after thisArg (arg1, arg2 etc), in order.
 

...

 

(21. Call the [[DefineOwnProperty]] internal method of F with arguments "arguments", PropertyDescriptor {[[Get]]: thrower, [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false}, and false.

 

(22. Return F.

###Second , let's see how it's implemented in Chrome.

Second , let's see how it's implemented in Chrome.

##Most of the time it does not matter.

##However yes, when it matters - .bind is slower

###First, let's look at the bind algorithm defined in the specification:

  1. Let Target be the this value.
  2. If IsCallable(Target) is false, throw a TypeError exception.
  3. Let A be a new (possibly empty) internal list of all of the argument values provided after thisArg (arg1, arg2 etc), in order.
 

...

 

(21. Call the [[DefineOwnProperty]] internal method of F with arguments "arguments", PropertyDescriptor {[[Get]]: thrower, [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false}, and false.

 

(22. Return F.

###Second , let's see how it's implemented in Chrome.

Most of the time it does not matter.

However yes, when it matters - .bind is slower

First, let's look at the bind algorithm defined in the specification:

  1. Let Target be the this value.
  2. If IsCallable(Target) is false, throw a TypeError exception.
  3. Let A be a new (possibly empty) internal list of all of the argument values provided after thisArg (arg1, arg2 etc), in order.

...

(21. Call the [[DefineOwnProperty]] internal method of F with arguments "arguments", PropertyDescriptor {[[Get]]: thrower, [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false}, and false.

(22. Return F.

Second , let's see how it's implemented in Chrome.

added 75 characters in body
Source Link
Benjamin Gruenbaum
  • 277.6k
  • 90
  • 524
  • 524

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/

Chrome 59 update: As I predicted in the answer below bind is no longer slower with the new optimizing compiler

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/

added 114 characters in body
Source Link
Benjamin Gruenbaum
  • 277.6k
  • 90
  • 524
  • 524

Chrome 59 update: As I predicted in the answer below bind is no longer slower with the new optimizing compiler

##Most of the time it does not matter.

##Most of the time it does not matter.

Chrome 59 update: As I predicted in the answer below bind is no longer slower with the new optimizing compiler

##Most of the time it does not matter.

added 3086 characters in body
Source Link
Benjamin Gruenbaum
  • 277.6k
  • 90
  • 524
  • 524
Loading
Source Link
Benjamin Gruenbaum
  • 277.6k
  • 90
  • 524
  • 524
Loading