Let's LRun ES6!

- classes -

@iam_keen

Today's story

Context

  • Story Line
  • Start Code
  • Function1
  • Function2
  • Prototype
  • When I use it?
  • EX6
  • Next Movie

Story Line#1

Story Line#2

Story Line#3

What does your father

do for a living?

He is a

Gangster.

WTF

Start Code

exports.assert = function(){
  console.log("유오성 :" + arguments[0]);
  if(arguments[0]===scripts["answer"]){
    console.log(scripts["explosion"]);
    console.log(scripts["ok_sign"]);
  }else{
    console.log(scripts["cut_sign"]);
  }
}
var obj1 = { answer: scripts.answer }
assert(obj1.answer);

Function1

var ft1 = exports.function1 = function ft1(){
        var answer = scripts.answer;
        var name="james";
}

assert(ft1.answer);

Object1

var obj1 = new ft1();
assert(obj1.answer);

Function2

var ft1 = exports.function1 = function ft1(){
        var answer = scripts.answer;
        var name="james";
}

assert(ft1.answer);

Object2

var obj2 = new ft2();
assert(obj2.answer);

Prototype

var ft3 = exports.ft2 = function(){
this.name="naruto";
}
ft3.prototype.answer =scripts.answer
assert(ft3.answer);

Obj3

var obj3 = exports.obj3 = new ft3();
assert(obj3.answer);

Obj2==Obj3?

When I use Protos

var Friends = function (name) { this.name = name; };
Friends.prototype.data = ["동수 마이 컸네", "원래 키는 내가 니보다 컸다 아이가", "하와이 가라"];
Friends.prototype.showData = function () { console.log(this.name, this.data); };
var actor1 = new Friends("이준석");
var actor2 = new Friends("한동수");

actor1.showData();
actor2.showData();
actor1.data.push("니가가라 하와이");

Let's LRun ES6!-classes

By Keen Dev

Let's LRun ES6!-classes

  • 765