Git Product home page Git Product logo

practical-modern-javascript's People

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

practical-modern-javascript's Issues

Schema Validation with Proxies possible error

There is a code on p. 195 (6.1.3 Schema Validation with Proxies) that isnt working for me.

const validations = new Map()
const validator = {
set(target, key, value) {
if (validations.has(key)) {
return validations[key](value)
}
return Reflect.set(target, key, value)
}
}

I suggest to change return validations[key](value) to validations(key)(value), because of:

  1. Map object dont support accessing through [], only through get method.
  2. If we return result of validation, we dont actually reach setting value at target[key]. If we just validate value by direct method call of validations object, as I suggesting, we throw error in that method if value isnt valid, or bypass this method in case of valid value and reach setting the value in Reflect.set.

Instructions to build epub / pdf /etc

I find that there are no instructions for someone to clone the repository and build an epub, pdf or other book format from the source. Is that something that is "common knowledge"? Maybe a small section in the Readme.md would be useful.

code snippet mismatch

The code is at the end of chapter 2.3.4.

It has a miswrite the '+' identifier in the sku: brand + ':' [] make

const getCarProductModel = ({ brand, make, model }) => ({
  sku: brand + ':' make + ':' + model,
  brand,
  make,
  model
})
getCarProductModel(car)

Screenshot of ESLint output seems a bit outdated

See https://github.com/mjavascript/practical-modern-javascript/blob/master/ch01.asciidoc#fig0102 and the previous code.

Currently, I get this output:

Code:
  1:12  error  Infix operators must be spaced                                                                                 space-infix-ops
  3:10  error  'hello' is defined but never used                                                                              no-unused-vars
  3:15  error  Missing space before function parentheses                                                                      space-before-function-paren
  3:17  error  Missing space before opening brace                                                                             space-before-blocks
  4:17  error  Requires a space before '}'                                                                                    block-spacing
  4:17  error  Closing curly brace should be on the same line as opening curly brace or on the line after the previous block  brace-style
  6:1   error  Expected space(s) after "if"                                                                                   keyword-spacing
  6:4   error  Unexpected constant condition                                                                                  no-constant-condition
  6:10  error  Missing space before opening brace                                                                             space-before-blocks

✖ 9 problems (9 errors, 0 warnings)
  7 errors, 0 warnings potentially fixable with the `--fix` option.�
                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

Maybe at least the line about extra semicolon can be deleted from the screenshot as most confusing (there is no semicolon in the code).

Mistaken example?

Hi. At the end of the 2nd chapter you provide the following piece of code saying:

When the items variable is changed to reference another list of items, we’re in for a world of hurt—the todo API still works with the value items used to have, but items is referencing something else now.

var items = ['a', 'b', 'c']
var todo = checklist(items)
todo.check()
console.log(items)
// <- ['b', 'c']
items = ['d', 'e']
todo.check()
console.log(items)
// <- ['d', 'e'], would be ['c'] if items had been constant
function checklist(items) {
  return {
    check: () => items.shift()
  }
}

IMHO items and the checklist function are just forming a closure. So once that todo var is created and items is referenced to another thing, it doesn't matter what is done to items, it's irrelevant to the code.

I'm just a hobbyist so I thought someone should take a look at it.

I think arrow functions create closures

The section Lexical Scoping https://ponyfoo.com/books/practical-modern-javascript/chapters/2#lexical-scoping-8zsxfqh9
claims that arrow functions don't create closures. It looks like they do. In fact, the code relies on closure of arguments in the evaluation of the returned function. I think this should say "arrow functions don't create their own lexical scope, so arguments is accessed from the closure of the enclosing function".

calc=((a)=>( (b)=>{debugger; return a+b} ))(a=1); calc(2)

Screen Shot 2019-06-15 at 15 08 04

chapter 2: code examples and descriptions are miscoordinated

It seems there is a conflict between some editions:

Consider the next snippet, where a property named code wouldn’t have been as indicative of its contents as colorCode could be:

var { metadata: { gender: characterGender } } = character

The scenario we just saw repeats itself frequently, because properties are often named in the context of their host object. While palette.color.code is perfectly descriptive, code on its own could mean a wide variety of things, and aliases such as colorCode can help you bring context back into the variable name while still using destructuring.

Spread Operator Syntax for Objects

This section suggests the Spread Operator syntax only works for iterable object literals. In fact, generic Object literal declarations also support spread operator assignment syntax:

"Note that the spread operator isn’t limited to arrays and arguments. The spread operator can be used with any iterable object. Iterable is a protocol in ES6 that allows you to turn any object into something that can be iterated over. We’ll research the iterable protocol in Iteration and Flow Control."

Screen Shot 2019-06-16 at 09 41 20

Is there another section where non-iterable Object Literal spread syntax is covered?

Inconsistent code style of template literals

In some places you put spaces inside curly braces:

const message = `The sum of ${ input.join(`+`) } is ${ sum }`

but in others you don’t:

const summary = `${units}x ${name} ($${unitPrice}) = $${totalPrice}`

Can't buy book

Why I can't buy book? Amazon is the worst choice for ebooks, because there is no way to get and read clean pdf.

  1. I use Ubuntu (Linux) and there is no software for ebooks from Amazon
  2. No pdf support (for my electronic device PocketBook)
  3. Reading online requires exposing a lot of confidential information
  4. Paperback is no choice for faraway countries like Russia (and I want to get updates)

Why shall I grant you:

  • Post Tweets for you
  • See your email address
  • Update your profile
  • Read Tweets from your timeline

Don't you think it is too much access rights for you? And violate privacy?
Why do you need such information about people?

It would be good to consider collaborating with other platforms such as Manning publishing (as they provide all formats) or PacktPub Publishing.

I suggest it might be a good book about modern Javascript, but the way how you distribute book gives no change to acquaint with it.

SyntaxError?

Line 297 of ch08.asciidoc.txt:

export count

I think it will cause SyntaxError too.

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.