Skip to content

Instantly share code, notes, and snippets.

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(
var Parent = function() {
this.print= function() {
alert("Parent, this.print");
};
};
var Children = function() {
/*
this.print=function() {
alert("Children, this.print");
var Parent = function() {
this.print= function() {
alert("My name is " + this.getName());
};
};
var Children = function(name) {
this.name = name;
this.getName = function() {
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/>");
function SUM() {
var result = 0;
for(var i in arguments) {
result += arguments[i];
}
alert(result);
}
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);
}
onload=function() {
var name;
$.getJSON("test.json", "", function(res) {
name = res.name;
});
alert(name);
}
onload=function() {
var name;
$.getJSON("test.json", "", function(res) {
name = res.name;
});
setTimeout(function() {
alert(name);
}, 100);
}
var test = [ { name : 'a' }, { name : 'b' }, { name : 'c' } ];
$.each(test, function(index) {
alert(index + " = " + this.name);
});
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) {