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
Array.prototype.each = function(callback) { | |
for(i = 0; i < this.length; i++) { | |
callback.prototype = this[i]; | |
new callback(i); | |
} | |
}; | |
var test = [ { name : 'a' }, { name : 'b' }, { name : 'c' } ]; | |
test.each(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 Test = function() { | |
this.print = function() { | |
alert("this.print"); | |
}; | |
}; | |
console.log(Test.prototype); |
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 = function() { | |
console.log(this); | |
this.print = function() { | |
alert("this.print"); | |
}; | |
}; | |
// 함수 호출 | |
Test(); |
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 = function() { | |
this.print= function() { | |
alert("this.print"); | |
}; | |
}; | |
Object.prototype.print= function() { | |
alert("Object.prototype.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 Test = function() { }; | |
Object.prototype.print= function() { | |
alert("Object.prototype.print"); | |
}; | |
Test.prototype.print= function() { | |
alert("Test.prototype.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 Test = function() { }; | |
Object.prototype.print= function() { | |
alert("Object.prototype.print"); | |
}; | |
new Test().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 Test = function() { | |
this.print= function() { | |
alert("this.print"); | |
}; | |
}; | |
Object.prototype.print= function() { | |
alert("Object.prototype.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 Test = function() { | |
this.print= function() { | |
this.constructor.show(); | |
}; | |
}; | |
Test.show = function() { | |
alert("Test.show"); | |
}; |
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 = function() { | |
this.print= function() { | |
alert("this.print"); | |
}; | |
var tt = new this.constructor(); | |
tt.print(); | |
}; | |
var ttt = new Test(); |