arcturo / library Goto Github PK
View Code? Open in Web Editor NEWA library of free eBooks we're working on
Home Page: http://arcturo.com/library/
A library of free eBooks we're working on
Home Page: http://arcturo.com/library/
Our eBook library. More coming soon...
trigger = (events...) ->
events.splice(1, 0, this)
this.constructor.trigger.apply(events)
when I invoke trigger(1, 2, 3)
it will raise exception:
TypeError: Cannot call method 'apply' of undefined
In last paragraph of Strict Mode Usage:
"Whilst I recommend enabling strict mode, but it's worth noting that script mode doesn't enable..."
Should say "strict mode doesn't"
In the part of the chapter that says
task 'build', 'Build lib/ from src/', ->
# Now we have access to a `options` object
we need an options argument:
task 'build', 'Build lib/ from src/', (options) ->
I translated the coffeescript book into Japanese, but I don't know how you handle translation.
Do you have any strategy on that? or can I just maintain it on my repo?
As it's my first translation on github, I don't even know how to contact the author for this kind of matter, sorry for posting on "Issue" :[
In the last sentence of the introduction:
"Now is definitely the time to jump on the CoffeeScript train, and you'll thank yourself for the time invested in learning about the language now, in lieu of the major time savings you'll make later."
"in lieu of" is not correct here, as it suggests the up-front investment is replacing later time savings.
"Now is definitely the time to jump on the CoffeeScript train. The time you invest in learning about the language now will be repaid by major time savings later."
According to the book (https://arcturo.github.io/library/coffeescript/03_classes.html) instance properties can be created in the following way:
class Animal
price: 5 # instance property according to the book
sell: (customer) ->
animal = new Animal
animal.sell(new Customer)
But when I checked generated JavaScript code it looks like price
property was added to the prototype ๐...
Well, if you try to use it I guess in that case it will magically work because the number type in JavaScript is immutable, but let me just show you an example with mutable field:
class Store
products: [] # instance property?
addProduct: (name) ->
@products.push(name)
foodStore = new Store
foodStore.addProduct 'milk'
motoStore = new Store
motoStore.addProduct 'tyre'
console.log motoStore.products # ['milk', 'tyre'], boom
So obviously products
property was added to the prototype and it's shared by both instances.
doesn't need Rail's other features and associated overhead
"...CoffeeScript wraps up scripts with a anonymous function..."
a should be an
This book is amazingly instructive, and by far the best primer to CS that I have found. But in Chapter 6 I find that you move too qucikly, and it's not clear to me how things are working together or where files are being placed. For example, having the index.html refer to application.js which is not created is confusing to me. But this would be cleared up just by having a directory with all of that source code in place.
Thanks!
expect of course it runs client side
Chapter 7 says:
"
If you're checking to see if an variable has been defined, you'll still need to use typeof otherwise you'll get a ReferenceError.
if typeof aVar isnt "undefined"
objectType = type(aVar)
Or more succinctly with the existential operator:
objectType = type(aVar?)
"
However, the two statements are NOT equivalent, because type(aVar?)
will unconditionally return "boolean"
, because applying the existential operator to a variable always returns a Boolean.
In coffeescript\02_syntax.html (264):
In the 2nd last para:
If you're using a null check before accessing a property, you can skip that by placing the existential operator right before the >opening parens. This is similar to Ruby's try method.
blackKnight.getLegs()?.kick()
I think that the text and code sample are conflicting. The text says:
placing the existential operator right before the opening parens
Whereas the code shows the existential operator after the parens
Hello, i encounter a problem in ch6, and the error info is below:
progress is not defined.
After i delete the progress relative code, it works...
"Functions can be one liners, or indented on multiple lines."
No comma needed.
Hi there!
Thanks for writing such a neat book!
In the sixth paragraph of "What is CoffeeScript?" is the sentence:
you'll get syntax errors if you compile JavaScript as-is
Which I believe should say "CoffeScript" instead:
you'll get syntax errors if you compile CoffeeScript as-is
In
"alert("This parrot is no more") if parrot.rip()"
rip isn't a function, so parentheses should be removed:
"alert("This parrot is no more") if parrot.rip"
It would be nice to include a link to the next page, at the bottom of each page. Or reuse the main-navigation.
It's kinda weird one has to go BACK to the main nav in order to CONTINUE.
Thank you!
names = sam: seaborn, donna: moss
alert("#{first} #{last}") for first, last of names
seaborn and moss need to be in quotes.
The objects need to be cloned before being added in order to prevent different classes extending the same mixin from referencing the same properties.
The example needs to be amended as such :
clone = (obj) ->
if not obj? or typeof obj isnt 'object'
return obj
newInstance = new obj.constructor()
for key of obj
newInstance[key] = clone obj[key]
return newInstance
moduleKeywords = ['extended', 'included']
class Module
@extend: (obj) ->
for key, value of obj when key not in moduleKeywords
@[key] = clone value
obj.extended?.apply(@)
this
@include: (obj) ->
for key, value of obj when key not in moduleKeywords
@::[key] = clone value
obj.included?.apply(@)
this
expect should be except
I like to read books in order and quickly exhaust myself clicking "<< back to all chapters" then selecting the next chapter instead of clicking a next chapter link.
In chapter 3 you are introducing instance properties. The syntax you are using is, in my opinion, not generating a instance property. The value is saved in the prototype of the class and not in this
. Additionally, if you initialize with an object the object will be shared between all instances and changes on it will apply to all instances.
I would recommend initializing an instance property in the constructor.
Please fix this as you are having a high google rank on a search for 'coffeescript property'.
an example shows:
alert(...) if parrot.rip()
but rip is defined as a property, not a method. It should be:
alert(...) if parrot.rip
In the function definition section of chapter 7:
"The is because of function scope." should be "This is because of function scope."
Don't forgot to include the parens
In chapter 1, it says:
In fact, you can use the browser-based CoffeeScript compiler yourself, by including this script in a
page, marking up any CoffeeScript script tags with the correct type.
But both the link in that paragraph (http://jashkenas.github.io/coffee-script/extras/coffee-script.js
) and the one used in the script below don't exist. I used https://raw.githubusercontent.com/jashkenas/coffeescript/master/extras/coffee-script.js
and that worked, but probably there is a better option.
Thanks for the book.
Using these as variable names in your JavaScript programs can unpredictable results
Change "...CoffeeScript lets you do that by specifying arguments in a pair of parenthesis before the arrow."
to
"...CoffeeScript lets you do that by specifying arguments in parentheses before the arrow."
Why not convert to markdown?
There's a minor typo in the Applications chapter of The Little Book on Coffeescript. In the part where we boot stitch up, a variable in the code is named package which seems to be a reserved keyword.
CoffeeScript version 1.3.3 throws up an error on the lines of:
SyntaxError: In repl, reserved word "package" on line 6
Here's the code in question:
package = stitch.createPackage(
# Specify the paths you want Stitch to automatically bundle up
paths: [ __dirname + "/app" ]
# Specify your base libraries
dependencies: [
# __dirname + '/lib/jquery.js'
]
)
P.s. Hats off for the great work! :)
I'm new to all this so maybe it's something I did wrong. But I had to add two more lines to package.json so that heroku would run the app successfully.
"underscore": "~1.3.1",
"async": "~0.1.15",
This idiom section implies that for... body
is also a comprehension like body for...
. I think it could be more clear that it's running a more tradition for loop with a body and the only value returned is the result of the last body and not all bodies.
In the "Aliases & the Existential Operator" section there are two javascript code snippets:
if (typeof brian !== "undefined" && brian !== null) {
praise;
}
and
var velocity;
velocity = typeof southern !== "undefined" && southern !== null ? southern : 40;
I think that "&&" operator is wrong, and there should be "||" instead.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.