Explanation
“@instance:” allows us to attach an object/value to the Foo class instead of Foo’s prototype. Recall that “@” in CoffeeScript refers to JavaScript’s “this”.
After “@instance:” there is a function that is immediately executed. This function returns a function, closed around a variable called instance. Both these functions have their context (their “this”) bound to the Foo object using CoffeeScript’s wonderful “define and bind” operator “=>” as opposed to the normal function definition operator “->”.
When called, the function that “@instance” ends up referring to simply checks to see if the “instance” variable is empty and if so, assigns a new instance of Foo to it. Newing up a Foo is done using the “@” symbol since the function’s “this” refers to the Foo object. It then returns the instance.
Output
The CoffeeScript above compiles down to this:
I think the admin of this web site is in fact working hard in support of his web site, for the reason that here every material is quality based stuff.
This piece of writing is truly a fastidious one it assists new the web users, who are wishing in favor of blogging.
Hi! This is my first comment here so I just wanted to give a quick shout out and tell you I truly enjoy reading your articles.
Can you suggest any other blogs/websites/forums that deal with the same subjects?
Thank you!
조용한 분위기의 평택호빠에 다녀와보세요 정말 힐링했어요