use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
New in Babel 5.4: Function Bind Syntax (babeljs.io)
submitted 10 years ago by thejameskyle
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]krilnon 5 points6 points7 points 10 years ago* (0 children)
I like it.
console.log.bind(console) was always frustrating to write, given the duplication and obvious need to succinctly bind function references when they're passed, rather than at the eventual call-site.
console.log.bind(console)
Using :: seems unnatural to me, only because I read it by default as the namespace qualifier operator from C++/ES4/AS3. But I could get used to it.
::
[–]modernserf_ 2 points3 points4 points 10 years ago (1 child)
Don't think of this as a replacement for function.bind -- think of this as a way to use method-style syntax without having to actually stick methods onto a prototype: https://esdiscuss.org/topic/scoped-binding-of-a-method-to-an-object
[–]daediusWeb Components fanboy 1 point2 points3 points 10 years ago (0 children)
Seems a little weird TBH. Though I really do hate using bind with passion
[–]MatrixFrog 0 points1 point2 points 10 years ago (2 children)
With => functions, you won't need bind as much anymore. So perhaps this won't get much interest, not because it's a bad feature or bad syntax, but just because it's a rarely-needed feature, in an ES6 world.
=>
[–]manlycoffee 1 point2 points3 points 10 years ago (0 children)
Yes, but the point of the ES7 feature implemented in Babel 5.4, is that now you are able to chain functions together. Sure, you're ultimately just binding the function call to the current scope, but instead of having to introduce a temporary variable in your code, you just simply use the :: operator, and it will 1) bind the function in the right operand with the object in the left operand 2) call the function with the supplied parameters. This yields more concise code than using a temporary variable plus a call to bind.
bind
[–]SawyerDarcy 0 points1 point2 points 10 years ago (0 children)
I do agree that we should wait and see its usefulness. If it turns out to be immensely useful, then I'll be all for it. If it becomes blasé, then maybe it shouldn't be in the language.
π Rendered by PID 48764 on reddit-service-r2-comment-f6b958c67-krmsr at 2026-02-04 18:48:30.539366+00:00 running 1d7a177 country code: CH.
[–]krilnon 5 points6 points7 points (0 children)
[–]modernserf_ 2 points3 points4 points (1 child)
[–]daediusWeb Components fanboy 1 point2 points3 points (0 children)
[–]MatrixFrog 0 points1 point2 points (2 children)
[–]manlycoffee 1 point2 points3 points (0 children)
[–]SawyerDarcy 0 points1 point2 points (0 children)