Live data from Hacker News

JavaScript: Function Invocation Patterns

doctrina.org

1–10 of 52 posts

Re: JavaScript: Function Invocation Patterns

#2
There's an error in his first 'Function Invocation' example, the answer is 500, not 501.

[Reason: 'this.value++;' in the method invocation refers to obj.value, since 'this' is bound to 'obj'. Only in the innerFunction function invocation does 'this' bind to the global object.]

Re: JavaScript: Function Invocation Patterns

#5
please see the HN guidelines http://ycombinator.com/newsguidelines.html

  Please don't do things to make titles stand out, like using 
  uppercase or exclamation points, or adding a parenthetical 
  remark saying how great an article is. It's implicit in 
  submitting something that you think it's important.
plus i have a very strong distain about anyone or anything (i.e. headlines) which tell me what i MUST do / know / think... - also the article above is about a very basic language feature of JS that hopefully anyone who has every touched JS already knows about.

Re: JavaScript: Function Invocation Patterns

#6
post #2

There's an error in his first 'Function Invocation' example, the answer is 500, not 501. [Reason: 'this.value++;' in the method invocation refers to obj.value, since 'this' is bound to 'obj'. Only in the innerFunction function invocation does 'this' bind to the global object.]

[deleted]

Re: JavaScript: Function Invocation Patterns

#7
post #5

please see the HN guidelines http://ycombinator.com/newsguidelines.html Please don't do things to make titles stand out, like using uppercase or exclamation points, or adding a parenthetical remark saying how great an article is. It's implicit in submitting something that you think it's important. plus i have a very strong distain about anyone or anything (i.e. headlines) which tell me what i MUST do / know / think..…

I agree this article is kind of javascript 101. And it doesnt do a great job explaining exactly why things are the way they are in javascript. And these are not patterns , since they are built in the language. It would be like saying using the world class in java is using a pattern... I dont see the point featuring it on HN...

Re: JavaScript: Function Invocation Patterns

#8
post #5

please see the HN guidelines http://ycombinator.com/newsguidelines.html Please don't do things to make titles stand out, like using uppercase or exclamation points, or adding a parenthetical remark saying how great an article is. It's implicit in submitting something that you think it's important. plus i have a very strong distain about anyone or anything (i.e. headlines) which tell me what i MUST do / know / think..…

Amusingly, the original title has a spelling mistake: "Javascript: Function Inovcation Patterns."

But enough burying the lede. The issue I have with this title is simple: It's not clear WHY I must know these patterns: The focus of the post is not why I must know them, but rather This post explains the four patterns, how to use them and what to watch out for. Had the post kicked off by explaining that not knowing one or more of these patterns could lead to disaster, I'd be onside with the submission title rewrite (sans emphasis).

Post reply on HN