L
Luke Matuszewski
Here are some questions that i am interested about and wanted to here
an explanation/discussion:
1. (general) Is the objectness in JavaScript was supported from the
very first version of it (in browsers) ? What about the new syntax of
creating a object using { 'propName1':'propValue1',
'propName2':'propValue2', 'propName3':{ /* another object */ } } - from
what version of JScript/JavaScript it was supported (from what browsers
versions) ?
2. (object-oriented) Every object has a prototype (and so on the
toString(), (other)... methods inherited from it). When i do sth like
this:
function MyConstr() {
var thisVar = this; /* Protected pattern */
var someProtected = 3; /* Protected pattern */
var this.thisVar = this; /* Public pattern */
/* here 'this' specifies the reference to the created object via 'new'
keyword */
this.myFunc = function () { /* Privilaged pattern */
/* here 'this' specifies the reference to ... what ?
1. to function myFunc context - so it points no more to the newly
created object via new MyConstr()
(thus someone could say it is buggy and should use thisVar)
2. to newly created object via new MyConstr();
*/
}
}
MyConstr.myFunc2 = function () { /* Public pattern */
/* here 'this' specifies the reference to ... what ?
1. to function myFunc2 context - so it points no more to the newly
created object via new MyConstr()
(thus someone could say it is buggy and should use this.thisVar)
2. to newly created object via new MyConstr();
*/
}
MyConstr.prototype.myFunc3 = function () {
/* here 'this' references to what object/contex ?
*/
}
Questions:
2.1 What is the difference between the myFunc and myFunc2 ? I know that
inserting function inside constructor takes more memory when
instantiating new objects than outside like myFunc2... but myFunc has
acces to someProtected variable and myFunc2 does not. Can anyone point
other differences ?
2.2 What about the issues with 'this' keyword ? (see more comments
about it in source code provided above - especially concerning about
what object/contex 'this' references)
2.3 Properties added outside the constructor body are accessible
without first creating an object right ? so one could say they are
static... is this correct ? (any other issues).
2.4 Any other suggestions on OOP in JS ? please write sth or provide a
link (i have read faq_notes on jiberring).
3. I have heard that statement
MyConstr.myFunc2 = function ()
was bad supported in IE5 ? (or maybe a new Function(...) construction).
Please provied a link/comment ?
Thats all i remember folks
Waitin for reply.
an explanation/discussion:
1. (general) Is the objectness in JavaScript was supported from the
very first version of it (in browsers) ? What about the new syntax of
creating a object using { 'propName1':'propValue1',
'propName2':'propValue2', 'propName3':{ /* another object */ } } - from
what version of JScript/JavaScript it was supported (from what browsers
versions) ?
2. (object-oriented) Every object has a prototype (and so on the
toString(), (other)... methods inherited from it). When i do sth like
this:
function MyConstr() {
var thisVar = this; /* Protected pattern */
var someProtected = 3; /* Protected pattern */
var this.thisVar = this; /* Public pattern */
/* here 'this' specifies the reference to the created object via 'new'
keyword */
this.myFunc = function () { /* Privilaged pattern */
/* here 'this' specifies the reference to ... what ?
1. to function myFunc context - so it points no more to the newly
created object via new MyConstr()
(thus someone could say it is buggy and should use thisVar)
2. to newly created object via new MyConstr();
*/
}
}
MyConstr.myFunc2 = function () { /* Public pattern */
/* here 'this' specifies the reference to ... what ?
1. to function myFunc2 context - so it points no more to the newly
created object via new MyConstr()
(thus someone could say it is buggy and should use this.thisVar)
2. to newly created object via new MyConstr();
*/
}
MyConstr.prototype.myFunc3 = function () {
/* here 'this' references to what object/contex ?
*/
}
Questions:
2.1 What is the difference between the myFunc and myFunc2 ? I know that
inserting function inside constructor takes more memory when
instantiating new objects than outside like myFunc2... but myFunc has
acces to someProtected variable and myFunc2 does not. Can anyone point
other differences ?
2.2 What about the issues with 'this' keyword ? (see more comments
about it in source code provided above - especially concerning about
what object/contex 'this' references)
2.3 Properties added outside the constructor body are accessible
without first creating an object right ? so one could say they are
static... is this correct ? (any other issues).
2.4 Any other suggestions on OOP in JS ? please write sth or provide a
link (i have read faq_notes on jiberring).
3. I have heard that statement
MyConstr.myFunc2 = function ()
was bad supported in IE5 ? (or maybe a new Function(...) construction).
Please provied a link/comment ?
Thats all i remember folks
Waitin for reply.