Od zera do JavaScript developera #4

Michal Staskiewicz

https://miksturait.slack.com/

http://bit.ly/miksturait

Agenda

  1. Values, Types, and Operators
  2. Functions &Data Structures - Objects and Arrays
  3. Higher-order Functions
  4. Objects &  first project
  5. Bugs, Errors & Regular Expression
  6. Modules & Asynchronous Programming
  7. Project - A Programming Language (review)
  8. ​Exercises - katas

Snack Challenge  Review

@Marcin

@kajetanboruta

@GrzesiekG

@Malwina 

@JakubM

@Dadii

@AndKaw

@Adrian

Code will be at GH (probably) today at night

Encapsulation

OOP

.call() and 'this'

function speak(line) {
  console.log(`The ${this.type} rabbit says '${line}'`);
}
let whiteRabbit = {type: "white", speak};
let hungryRabbit = {type: "hungry", speak};

whiteRabbit.speak("Oh my ears and whiskers, " +
                  "how late it's getting!");
// → The white rabbit says 'Oh my ears and whiskers, how
//   late it's getting!'
hungryRabbit.speak("I could use a carrot right now.");
// → The hungry rabbit says 'I could use a carrot right now.'

Prototypes

Symbols

let sym = Symbol("name");

Classes

class Rabbit {
  constructor(type) {
    this.type = type;
  }
  speak(line) {
    console.log(`The ${this.type} rabbit says '${line}'`);
  }
}

First Project!

Visual Studio Code

Game of Life

Create GameOfLife class

It should take one parameter(array) which determinate live cells and store it under cells property and size which determinate grid size (eg. 10 -> 10 x 10 cells)

Create method that setup grid based on size every cell should looks like

{ alive: false }

Create method that will setup initial cells from constructor to grid state

Create method for printing actual grid state

chars: 9634, 9632

Create the method calculates alive neighbours for given cell

Create method that will updates grid to the next epochs based on neighbours

Create method that will calculate next epoch every 1 second

Snack Challenge

Deadline - Środa 11.07 18:00

Exercises from this topic

Thanks! =>

Made with Slides.com