Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Back to the future of JS

Back to the future of JS

Slides form JSConf EU talk.

E807477655ad7125c8731065178030e2?s=128

Willian Martins

June 02, 2018
Tweet

More Decks by Willian Martins

Other Decks in Technology

Transcript

  1. Hallo!

  2. https://github.com/tc39/proposals

  3. None
  4. @wmsbill What is this?

  5. @wmsbill this in the global scope Browser - window Web

    worker - self NodeJS - module.exports
  6. @wmsbill this inside a function?

  7. @wmsbill this inside a function?

  8. None
  9. @wmsbill How to make this predictable? Reasoning the value of

    this is tricky Function.prototype.bind Arrow function () => {}
  10. With .bind()

  11. With Arrow

  12. @wmsbill Calling a knowing function

  13. @wmsbill Extracting a method from an object

  14. None
  15. @wmsbill Two syntaxes Unary : :context.method() Binary context: :method()

  16. @wmsbill Binary syntax

  17. @wmsbill Unary syntax

  18. @wmsbill

  19. @wmsbill

  20. @wmsbill

  21. @wmsbill Bind operator is good for virtual methods But relies

    on this to be bound
  22. @wmsbill Composing without this

  23. @wmsbill

  24. @wmsbill

  25. None
  26. @wmsbill Pipeline operator |> It is a syntax sugar for

    function composition It creates a way to streamline a chain of functions
  27. @wmsbill Pipeline operator |>

  28. @wmsbill

  29. @wmsbill

  30. @wmsbill

  31. @wmsbill Function with more params

  32. @wmsbill Function with more params

  33. @wmsbill Awaiting a function

  34. @wmsbill Awaiting a function

  35. @wmsbill Awaiting a function

  36. @wmsbill Awaiting a function

  37. @wmsbill Awaiting a function

  38. None
  39. @wmsbill Smart pipeline

  40. @wmsbill Smart pipeline Two types bare style and topic style

    () or [] are disallowed in bare style When () or [] is needed, topic style is used # token is subject to change
  41. @wmsbill What about curry?

  42. @wmsbill F# pipeline proposal Extends the minimal proposal with an

    await step Await step waits for the resolution of the previous step
  43. @wmsbill F# pipeline proposal

  44. @wmsbill

  45. @wmsbill Partial application f(…) arity = n; partialapp(f(…)) arity =

    m; m < n
  46. @wmsbill

  47. @wmsbill

  48. @wmsbill Partial application in ES Achievable by Function.prototype.bind .bind() binds

    context and parameters
  49. @wmsbill

  50. @wmsbill What about currying? We can achieve partial application with

    curry Curry ≠ Partial application Curry returns arity n-1
  51. @wmsbill

  52. @wmsbill Partial application with arrow function

  53. None
  54. @wmsbill Partial application proposal Creates two new parameters tokens ?

    For single argument . . . for multiple parameters
  55. @wmsbill Partial application syntax

  56. @wmsbill With arbitrary parameter

  57. None
  58. @wmsbill The . . . token Spread the unbound parameters

    Useful when you want to bound first or last parameter
  59. @wmsbill The . . . token

  60. @wmsbill The . . . token

  61. None
  62. @wmsbill Partial application + pipeline

  63. @wmsbill Partial application + pipeline

  64. @wmsbill Should I use all of it in production? These

    proposal are in very early stage The adoption of one, may change the syntax/semantics of other Not production ready (yet)
  65. https://medium.com/@wmsbill https://twitter.com/wmsbill wmsbill@gmail.com

  66. Dankeshön!