Git Product home page Git Product logo

thejsway's Introduction

The JavaScript Way

This repository contains the English source files for The JavaScript Way book.

You may browse its content here, but a nicer alternative is the online version which is free to read.

This book is also available on Leanpub (PDF, EPUB), Amazon (Kindle, paperback) and Educative (interactive course).

Book cover

Development notes

The online version of the book is powered by Material for Mkdocs. To deploy it locally, clone or download this repository, install poetry then run the following commands in the cloned/downloaded folder:

poetry shell
poetry install
mkdocs serve

By default, the book is deployed at http://localhost:8000 on the local machine.

License

This work is published under a Creative Commons license. All code is licensed under an MIT license. Contributions are most welcome.

Copyright © 2017-present Baptiste Pesquet.

thejsway's People

Contributors

abgutmann avatar agcb avatar atomicbit avatar baraban35 avatar barbaralaw avatar bpesquet avatar conradknapp avatar dancodes avatar derekhouck avatar fbialek avatar florianloch avatar foleydom avatar frankpf avatar freeslugs avatar ganeshk254 avatar jamais avatar jingman avatar juhaniniinimaa avatar me-shaon avatar mechmillan avatar mtrivera avatar opheron avatar rainierlouis avatar scottyrotten avatar theo-armour avatar tompao avatar uberrobert avatar vsemozhetbyt avatar wfriesen avatar yiosh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

thejsway's Issues

ch18 animation error

When I ran the code in thejsway/chapter18.md at master · bpesquet/thejsway, I got the error "block not defined" from const blockWidth = parseFloat(getComputedStyle(block).width);. So I replaced the block with blockElement, but there is another error "ch18-2.html:9 Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.
at moveBlock (ch18-2.html:9)". I ran this program in Chrome, and the source code is

<head>
    <script>
      const moveBlock = () => {
        const xBlock = parseFloat(getComputedStyle(blockElement).left)
        const xMax = parseFloat(getComputedStyle(frame).width)
        if (xBlock + blockWidth <= xMax) {
          blockElement.style.left = (xBlock + movement) + 'px'
          animationId = requestAnimationFrame(moveBlock)
        } else {
          cancelAnimationFrame(animationId)
        }
      }

      const frameElement = document.getElementById("frame")
      const blockElement = document.getElementById("block")
      const blockWidth = parseFloat(getComputedStyle(blockElement).width)
      const movement = 7

      let animation = requestAnimationFrame(moveBlock)
    </script>
    <link href="ch18-2.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="frame">
  <div id="block"></div>
</div>
</body>

Where have I done wrong?

Upper case letter missing -> chapter 20

In the Web clients section there is this text:

Actually, the real client is a software program running on the machine. a well-known type of web client is the...

Since there is a full stop (dot) after the word machine, I think the next word (the article a in this case) should start with an upper case letter.

chapter17 event word

In this part of chapter 17.

You can event cancel the request to the server by calling the preventDefault() method on the Event object associated to the event.

Is this 'event' here should be replaced by 'even' instead?

Error on Chapter 14

// Get all h2 elements into an array const titleElements = document.getElementsByTagName("h2"); console.log(titleElements[0]); // Show the first h2 console.log(titleElements.length); // 2 (total number of h2 elements in the page)

There should be 3 h2 elements. And the corresponding picture14-07 is not correct.

Picture14-01 and picture14-02 lack a few lines of code.

An ambiguity in the chapter05.md

When it's done, update the program so that it shows the square of every number between 0 and 10.

Should it be mentioned that this program will not need parameters/arguments anymore?

Missing "instead" in chapter07.md

In the "Adding an element to an array" section, the sentence:

"To add an element at the beginning of an array, use the unshift() method of push()."

should probably be:

"To add an element at the beginning of an array, use the unshift() method instead of push()."

Chinese version

Can I translated this fantastic book into chinese on github?

Wrong word Chapter 18

In the first paragraph of the "Start an animation" section, there is this sentence:

It grabs the current position of the block's left border than adds the value contained in the movement variable.

I think the there's a typo in the word "than", seems like it is "then" the correct one!

Indonesian version

Hello,
any possibilities whether I can translate it to Indonesian ? thanks

Syntax error in Character class example/Chapter 9

if (target.health > 0) {
        console.log(`${target.name} has ${target.health} health points left`);
      } else {
        target.health = 0;
        const bonusXP = 10;
        console.log(
          `${this
            .name} eliminated ${target.name} and wins ${bonusXP} experience points`
        );
        this.xp += bonusXP;

In this if statement the line
${this.name} eliminated ${target.name} and wins ${bonusXP} experience points
Should be one line.

chapter 22 > weather

Hello, on the Key-based authentication chapter, the API access key is not free anymore. I made an account and when I went to the weather API for developers sublink found this:

To improve our services and enhance our relationship with our users, we will no longer provide free weather API keys as part of our program. If you have been directed to download our Weather Underground free API key by a third party provider, please contact your vendor for resolution.

P.s thank you for the great book 👍

chapter10.md: some missing lines of codes

At the "Splitting the program into functions", the particular code is written as:
// Get movies by Christopher Nolan const nolanMovies = () => { for (const movie of movieList) { if (movie.director === "Christopher Nolan") { nolanMovieList.push(movie); } } };

Where it should be:
// Get movies by Christopher Nolan const nolanMovies = () => { const nolanMovieList = []; for (const movie of movieList) { if (movie.director === "Christopher Nolan") { nolanMovieList.push(movie); } } return nolanMovieList; };

Add Solutions Repo

Would be useful if there is a solutions repo for the exercises for people who get stuck.

chapter02.md: some vagueness

For number variables, the operators += and ++ can increment (increase by 1) their value.

+= can increase more than by 1 (a += 2).

You can also increase or decrease a value of a number with += and ++.

Should the -= and -- be mentioned to match "decrease"?

In JavaScript and many other programming languages, a code block is a portion of a program delimited by a pair of opening and closing braces. By default, a JavaScript program forms one block of code.

let nb1 = 0;
{
  nb1 = 1; // OK : nb1 is declared in the parent block
  const nb2 = 0;
}
console.log(nb1); // OK : nb1 is declared in the current block
console.log(nb2); // Error! nb2 is not visible here
  1. Maybe it is worth to be noted that a file can produce a code block (scope) without braces (otherwise "parent block" can be confusing for beginners here).

  2. I may be wrong, but nb abbreviation is not common for "number" in English (compare: https://fr.wikipedia.org/wiki/NB vs https://en.wikipedia.org/wiki/NB). Maybe num is more usual (if you decide to replace, do not forget places like this)

Plans for content less web-related?

Hi. This has been a great resource so far. Are there any plans of expanding it so it's more about writing JavaScript logic that is not related to a DOM?

Contributing Additional Exercises

I have a number of exercises that I have been using for years that I would also like to integrate or reference at appropriate points in the book. What is the best way to do this? I see two ways:

  1. Add them to the book itself
  2. Add them as separate repos and refer to them in book

Given the growing popularity of the book, I propose exercise contributions be kept in their own repos, maintained by their own contributors, and that some way to reference these additional exercises be added to the book itself in order to inform readers that they exist, perhaps in a special Forward. This way the book itself will not be overwhelmed with exercises and readers can identify their preferred set of exercises based on their interests and needs.

Chapter 14 -> missing word

I'm not sure but seems like the word "method" is missing between contains() and "on":

...by calling the contains() on the class list,

The sentence it's in the Classes section.

Chapter 06 - arrays named "values"

In the "Sum of values" and "Array maximum" problems at the end of Chapter 6, students are asked to:

Write a program that creates the following array, (...)
const values = [3, 11, 7, 2, 9, 10];

Following these instructions will lead to problems when attempting to do anything with the array, as values is interpreted as the Object.values() method.

const myArray = [1, 2, 3]
myArray.forEach(element => console.log(element))
// behaves as expected

const values = [1, 2, 3]
values.forEach(element => console.log(element))
//TypeError: values.forEach is not a function

Naming the array something else like "numbers" might avoid some confusion.

translation into Chinese

@bpesquet Hello Sir I'd like to participate in the translation of this nice book to Chinese. Any repo or team already built ?

Tks in advance

Machine language != Assembly language

First: thanks for making this book available!

I just came across the following in intro02.md:

The only programming language directly understandable by a computer is machine language, also known as assembly language.

I believe this is incorrect... Machine language and assembly are actually two distinct things. Machine language usually refers to the actual binary format understood by the processor, that is, the set of ones and zeros that you feed into it to make it do stuff. Assembly, on the other hand, is a (barely) human-readable language that translates nearly one-to-one into machine code... but not quite. One substantial difference of assembly is the ability to use abstract labels for jump locations and have the jump address offsets computed automatically (instead of having to compute them manually, and then having to change them all any time you add/remove any code between them): https://stackoverflow.com/a/3551967 . Also, in some cases assembly language include pseudo-ops, which don't always translate to the same machine instruction or which translate to multiple machine instructions: https://stackoverflow.com/a/40784745 .

Hope that helps!

Console output of strings can be confusing for beginners

In the chapter01.md, there are screenshots of some console outputs, They show strings in quotes, but console.log() produces string output without quotes (at least in the last Chrome, Firefox, and Node.js). Could it cause some confusing for beginners?

Added PR for chapter 6 - Strings

Salut @bpesquet

I added a PR for chapter 8 - Strings

It is worth noting that once you accept these pull requests, the document becomes a multi-author document

I note that you do not have a copyright notice. Legally copyright notices are no longer required - though many authorities advise including one.

https://en.wikipedia.org/wiki/Copyright_notice#Reasons_to_include_an_optional_copyright_notice

May I suggest adding thee words to the LIVENSE page:

copyright © 2017 The JavaScript Way authors

Also in your LICENSE page you include the Creative Commons advisory text before and after the actual license. You might consider deleting the CC comments.

Theo

leave vs let -> Chapter 18

In the "An alternative: CSS animations" section, there is a comment in one of the lines of code that says:

/* Let the block in its final position */

First of all, I should note I'm not a native English speaker. But, I think the word you meant instead of let it is "leave". Let as long as I know, gives the sense (among others) of allowing or making something to happen, and leave is it more similar to putting something in somewhere.

By the way, is it ok to open an issue for each think I notice as I'm advancing in the translation, or do you prefer I collect all of them and open only one issue in each chapter. I do no not want to become anoying!

function instead of functions -> Chapter 18

At the end of the "Stop an animation" section, there is this paragraph:

The cancelAnimationFrame() functions stops the animation and takes the ID of the animation set by a prior call to requestAnimationFrame().

In the previous code to this paragraph the function cancelAnimationFrame() is only used once. So, I think the word function must be singular and not plural! Seems like just a typo!

broken link / Chapter 17

the following text contains a broken link:
For a more general recap on forms, check out this course chapter on OpenClassrooms.

By the way, what should I do with these links in the spanish version? With sources from the MDN or wikipedia I just replace them with their spanish equivalent, but with some other souces there is no spanish version. In a previous chapter I chose another source from the wen on the same topic, but I don't know if this is correct or allowed.

An ambiguity in the chapter04.md

Improve the program so that it also shows odd numbers. Improve it again so that the initial number is given by the user.

This program must show exactly 10 numbers including the first one, not 11 numbers!

If the initial number is given by the user, could this program show less than 10 numbers?

Pull request for chapter on arrays - a sample of suggestions

Salut @bpesquet

Thank you for creating this simple, readable, modern introduction to my favorite language.

I really enjoy that you are living in the present/future and ignoring all the outdated stuff.

Separately, I am making a pull request for some suggestions for your chapter on Arrays.

If you like this effort, then I can keep on working on the other chapters.

Theo

Correct typo in charter 18

  • Typo:

Section: https://github.com/bpesquet/thejsway/blob/master/manuscript/chapter18.md#kick-off-a-repeated-action

which can bu used to further modify it => which can be used to further modify it

`// Move the block to the left
const moveBlock = () => {
// Convert the left position of the block (value of the form "XXpx") to a number
const xBlock = parseFloat(getComputedStyle(blockElement ).left);
// Move the block to the right
blockElement .style.left = (xBlock + movement) + "px";
// Have the browser call moveBlock as soon as possible
requestAnimationFrame(moveBlock);
};

const frameElement = document.getElementById("frame");
const blockElement = document.getElementById("block");

// Movement value in pixels
const movement = 7;

// Start the animation
requestAnimationFrame(moveBlock);`

Thanks,
Phuc Thai

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.