This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Unit = function() { | |
this.attack = function(unit) { | |
$("body").append(this.type + " 유닛인 '" + this.name + "'이(가) '" + unit.name + "'를 공격<br/>"); | |
// 공격 대상 유닛의 attacked 메소드 호출 | |
unit.attacked(this); | |
} | |
this.attacked = function(unit) { | |
$("body").append( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Parent = function() { | |
this.print= function() { | |
alert("Parent, this.print"); | |
}; | |
}; | |
var Children = function() { | |
/* | |
this.print=function() { | |
alert("Children, this.print"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Parent = function() { | |
this.print= function() { | |
alert("My name is " + this.getName()); | |
}; | |
}; | |
var Children = function(name) { | |
this.name = name; | |
this.getName = function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var BionicUnit = function(name, type) { | |
this.name = name; | |
this.type = type; | |
this.recovery = function(number) { | |
$("body").append("'" + this.name + "'의 체력이 " + number + "만큼 재생<br/>"); | |
} | |
this.move = function(distance) { | |
$("body").append("1. " + type + " 유닛인 '" + name + "'이(가) " + distance + "만큼 이동<br/>"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function SUM() { | |
var result = 0; | |
for(var i in arguments) { | |
result += arguments[i]; | |
} | |
alert(result); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function alram(min, callback) { | |
var isCall = false; | |
setInterval(function() { | |
var date = new Date(); | |
var nowMin = date.getMinutes(); | |
if(nowMin == min && !isCall) { | |
isCall = true; | |
callback(nowMin); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onload=function() { | |
var name; | |
$.getJSON("test.json", "", function(res) { | |
name = res.name; | |
}); | |
alert(name); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onload=function() { | |
var name; | |
$.getJSON("test.json", "", function(res) { | |
name = res.name; | |
}); | |
setTimeout(function() { | |
alert(name); | |
}, 100); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var test = [ { name : 'a' }, { name : 'b' }, { name : 'c' } ]; | |
$.each(test, function(index) { | |
alert(index + " = " + this.name); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var each = function(arr, callback) { | |
for(i = 0; i < arr.length; i++) { | |
callback(i, arr[i]); | |
} | |
}; | |
onload=function() { | |
var test = [ { name : 'a' }, { name : 'b' }, { name : 'c' } ]; | |
each(test, function(index, elem) { |