Wednesday, February 24, 2010

JavaScript Object Oriented - תכנות מונחה עצמים

אני יודע שכבר מאות פוסטים נכתבו על הדבר הזה, אבל תמיד נוח שיש משהו מרוכז במקום אחד,
ולכן כמה דוגמאות פשוטות ליצירת אובייקטים ב - JavaScript והשימוש בהם.


// declartion class a with private function
function x()
{
this.id = 0;

function getid()
{
// undefined - because this meanse the private
alert('x' + this.id);function
}
getid();
}
var nx = new x();
// error - undefined cuz it is private function
//x.getid();
x();


// declartion class a with public function
function a()
{
this.id = 0;

this.getid = function()
{
alert('a' + this.id);
}
this.getid();

}

// using class a
var b = new a();
b.getid();

// object creation on the fly
var o = {
id: 0,
getid: function()
{
alert('o' + this.id);
}
}

o.getid();

Tuesday, February 23, 2010

למה BreakPo?

כל מתכנת יודע על: int 3
ולכן על אותו משקל BreakPo, כמעשה הדברים, שים לי breakpo תוך כדי השענות קדימה והצבעה על שורה במסך.