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

Immutable In JavaScript

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

Immutable In JavaScript

Avatar for kvzhuang

kvzhuang

May 03, 2018
Tweet

More Decks by kvzhuang

Other Decks in Technology

Transcript

  1. Agenda ◉ Part I. Immutable ◉ Comparison after Shallow copy/deep

    copy in JavaScript ◉ React shouldComponentUpdate ◉ Immutable in JavaScript ◉ Why Immutable.js ◉ Part II. Functional Programming
  2. Swallow copy syntax sugar ◉  JS   deep

    copy  ◉ Recursive  copy ◉  JS deep compare   ◦  recursive  
  3. Agenda ◉ Shallow copy/ deep copy in JavaScript ◉ React

    shouldComponentUpdate ◉ Immutable in JavaScript ◉ Why Immutable.js
  4. Immutable In JavaScript ◉ Immutable Data  ! ( 

    !#% ' ◉  #%( " '  $ &'(Immutable.js )
  5. Agenda ◉ Shallow copy/ deep copy in JavaScript ◉ React

    shouldComponentUpdate ◉ Immutable in JavaScript ◉ Why Immutable.js
  6. Immutable.js ◉   JS /Map/Array … Mutable  

    Immutable   ◉  API   deep compare / deep copy.
  7. Recap ◉ Shallow Copy / Deep Copy, ◦ Deep comparison

    ◉  React shouldComponentUpdate ◉ Immutable / Mutable ◦ Mutable is Dangerous ◉ Immutable.js ◦ Structure Sharing
  8. Wiki In computer science, functional programming is a programming paradigm—a

    style of building the structure and elements of computer programs—that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data In functional code, the output value of a function depends only on the arguments that are passed to the function, so calling a function f twice with the same value for an argument x produces the same result f(x) each time Part II Functional Programming
  9. Wiki In computer science, functional programming is a programming paradigm—a

    style of building the structure and elements of computer programs—that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data In functional code, the output value of a function depends only on the arguments that are passed to the function, so calling a function f twice with the same value for an argument x produces the same result f(x) each time Part II Function Programming
  10. Function Programming  ◉ Avoid Mutation State ◉ Recursion ◉

    Higher-Order Function ◉ Function Composition ◉ ….etc Part II Function Programming
  11. ◉     Function ◉  Currying ◦

     N  function ◦  1 N  function Function Composition
  12.  # JavaScript )$ mutable data   JS 

     % Functional Programming "!(# + Redux  Selector   pure function '*- & Function Programming Immutable !(, Part II Function Programming