7 ms·
An Open Source Book That Teaches JavaScript
- zhte415 3y agoSuper. A book offers structure to get going. 'By example' is great too. As is 'read the manual'. [Good to have all, I like books.] Getting a structure filled out takes a fair bit of effort. That hurdle's overcome. On Github, its easy to fork / contribute - the tools are right there along with a creative commons (or, Apache in this case) license. Structure, content, license and tools are all there.
- dontchooseanick 3y agoCommenting on the last exercise, "loops" on https://javascript.sumankunwar.com.np/ https://javascript.sumankunwar.com.np/ The average functional programmer writes this - and not a for loop : ```` const fizzbuzz = (n)=>(n%15==0)?"FizzBuzz":(n%5==0)?"Buzz":(n%3==0)?"Fizz":n; Array(101).fill(0).map((_,i)=>fizzbuzz(i)) ````
- metalliqaz 3y agoI don't think that was the intention of the exercise.
- simonw 3y agoThat's covered in a later chapter: https://javascript.sumankunwar.com.np/arrays/map.html https://javascript.sumankunwar.com.np/arrays/map.html
- LordDragonfang 3y agoArray(101).fill(0).map((_,i)=> [...]) It's astonishing to me that even with all the niceties added to ES7+, JS still needs to resort to a hack like this for a simple range generator. At least give iterators support for forEach(), reduce(), and map(), so we can use `Array(100).keys()` without having to wrap it with the spread operator. Also, can't help but snark that apparently the "average" FP is so preoccupied with showing off their one-liners that they fail the problem requirements (should be `Array(100).fill(0).forEach((_,i)=>console.log(fizzbuzz(i+1)))`).
- graftak 3y agoA little bit better: Array.from({ length: 100 }, () => ...)
- iamsaitam 3y agoIndeed, much cleaner to do `Array.from({length: 100}, (_,i) => fizzbuzz(i));`
- LordDragonfang 3y agoWhile we're cleaning it up: fizzbuzz = i => (i % 3 ? "" : "Fizz") + (i % 5 ? "" : "Buzz") || i Array.from({length: 100}, (_,i) => console.log(fizzbuzz(i+1)))
- boringuser2 3y agoActual developers just use lodash. Honestly, I don't understand the complaint, a lean stdlib isn't a shortcoming.
- LordDragonfang 3y ago...It absolutely is a shortcoming. Python is the second-most popular language out there, despite its awful performance, largely because of its comprehensive stdlib. (First is JS, because web). And I don't understand how you can't see the irony of praising a "lean" stdlib immediately after saying every "actual" developer has to add the bloat of importing lodash.
- boringuser2 3y agoAgain, a lean stdlib is a feature, not a bug. You can have theoretical disagreements with this, but you didn't invent the most popular programming in the world. As for Python, not interested, it's mostly a "performance doesn't matter, being able to do this without expertise, time or even necessarily intellect does" niche. JS has been slow to roll in core functionality, but is has made great strides by being highly conservative, not generating the kind of bloat that PHP has.
- chrizel 3y agoAnother excellent and also OpenSource book, which I used a couple of years ago to refresh my knowledge about modern JavaScript is Eloquent JavaScript by Marijn Haverbeke. Highly recommended. https://eloquentjavascript.net/ https://eloquentjavascript.net/
- bouvin 3y agoI came here to recommend the very same. The interactive code examples are also very good for students.
- charlieyu1 3y agoJust took a quick look, this is actually interesting and worth reading even after passing the beginner stage
- boringuser2 3y agoI credit that book to me going from no college degree to principal developer.
- pmoriarty 3y agoHas anyone here successfully learned any programming languages with the help of ChatGPT? I feel like we might be entering a new era of education with these LLMs, who will patiently tutor you and answer your every question (not perfectly yet, but we're getting there).
- suddenclarity 3y agoThe problem is still that you have no idea what is true and what is made up. Especially as a learner. On my last attempt it gave me a disguised infinity loop that ate up all the ram and frooze the computer. I believe AI will be amazing for traditional language learning with voice recognition but it really needs to improve to be useful in other areas where facts actually matter. Maybe it can be solved by toning it down so it's less convincing and stop making up things. If that's at all possible.
- rozal 3y agoI asked mine to code a game and I got an infinity stone in the mail, the yellow one. Weird.
- boringuser2 3y agoUnfortunately LLMs, even the best one I'm aware that exists (GPT-4), aren't reliable.
- azangru 3y agoDoes anyone else get frustrated when they see, in blogs, articles, or books, introductions such as this: > Computers are common in today's world, as they are able to perform a wide variety of tasks quickly and accurately. They are used in many different industries, such as business, healthcare, education, and entertainment, and have become an essential part of daily life for many people. Besides this, they are also used to perform complex scientific and mathematical calculations, to store and process large amounts of data, and to communicate with people around the world. Anyone who would open this book must already know all this. Is there anyone who does not know that computers are everywhere? Does any prospective reader of a book on programming feel that computers are not essential? Does anyone doubt that complex scientific and mathematical calculations are made on computers? Who is this paragraph for? Who has taught us not to proceed straight to business?
- rzzzt 3y agoThe book has to start somehow. Would it be better if it featured cartoon foxes? Chunky bacon?
- rambojohnson 3y agothe point is that it should start without pointing out obvious banalities.
- copymoro 3y ago[dead]
- azangru 3y agoMuch better! I miss _why.
- layman51 3y agoYou have a point. But I think as a layman I would have appreciated a little more about what kind of reader the book is appropriate for. And possibly have that appear within the first three paragraphs of the intro. I like how this book does give you an idea of how you should expect to work through the examples though.
- agilob 3y agoWe used to have stackoverflow docs for it and it was great
- hayley-patton 3y ago> JavaScript is an interpreted language. While running Javascript an interpreter interprets each line and runs it. The modern browser uses Just In Time (JIT) technology for compilation, which compiles JavaScript into executable bytecode. This in the intro can't be of much use. Sure, it's an introductory book, but this isn't a correct simplification. Is JavaScript run by an interpreter or a compiler now? The quote can't decide; and the final stage of JavaScript JITs tends to be machine code too. I know there's often both (with interpreter for cold code, compiler for hot code); but given the level of the rest of the intro, throwing terms like "interpreted", "just in time", "compilation" and "bytecode" which haven't been defined would only lead to confusion, nor are they too relevant.