Skip to content

Instantly share code, notes, and snippets.

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