Skip to content

Instantly share code, notes, and snippets.

@pycraft114
Created March 16, 2017 01:20
Show Gist options
  • Save pycraft114/fe88bc376f37de6bdaa745e3fa4b2e65 to your computer and use it in GitHub Desktop.
Save pycraft114/fe88bc376f37de6bdaa745e3fa4b2e65 to your computer and use it in GitHub Desktop.
function Health(name,lastname){
this.name = name;
this.lastname = lastname;
}
var a = Health("chanwoo","park"); //return값이 없기때문에 a는 언디파인드, 윈도우에 네임 변수를 생성했기때문에 'chanwoo'출력
console.log(name);
var allFuntions = {
addtask:function(task){
this.todolist.push(task);
},
completedTask:function(task){
var index = this.todolist.indexOf(task);
this.completed.push(task);
this.todolist.splice(index,1);
},
showList:function(){
console.log(this.todolist);
}
};
function Mytask(){
this.todolist = [];
this.completed = [];
}
Mytask.prototype = allFuntions;
var firstTodolist = new Mytask();
firstTodolist.addtask("공부하기");
firstTodolist.addtask("idkidk")l
firstTodolist.completedTask("공부하기");
firstTodolist.showList();
var secondTodolist = new Mytask();
secondTodolist.addtask("크롱한테 사탕받기");
secondTodolist.showList();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment