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:
It’s going to be finish of mine day, however before ending I am
reading this wonderful piece of writing to improve my knowledge.
I always spent my half an hour to read this
website’s posts daily along with a mug of coffee.
Greetings! Quick question that’s completely off topic. Do you know how to make your site mobile friendly?
My web site looks weird when browsing from my apple iphone.
I’m trying to find a theme or plugin that might be able to fix this issue.
If you have any suggestions, please share. Many thanks!
Hello! Do you use Twitter? I’d like to follow you if that would be okay.
I’m absolutely enjoying your blog and look forward to new updates.
What’s up Dear, are you truly visiting this site on a regular basis,
if so afterward you will absolutely take good know-how.
you’re really a excellent webmaster. The site loading pace is incredible.
It kind of feels that you are doing any distinctive trick.
Also, The contents are masterpiece. you’ve performed a great job on this topic!
Ahaa, its good conversation on the topic of this piece
of writing at this place at this blog, I have read all that, so
at this time me also commenting here.
I relish, cause I discovered exactly what I used to be looking for.
You have ended my four day lengthy hunt! God Bless you man.
Have a nice day. Bye
Awesome things here. I am very satisfied to look your post.
Thanks a lot and I am taking a look ahead to touch
you. Will you kindly drop me a e-mail?