nolachrymose
07-30-2002, 02:07 PM
Right now I'm just playing around (not that I ever do any work anyways :D) with object prototypes. With the predefined objects you can change the value of "this" (so that the value of the object would be the value of this). I've had this error [invalid assignment left-hand side, line 8, char 7] before when I did this, and was just wondering if there was a way to work around it. Code is below.
<html>
<head>
<title>Setting "this"</title>
<script type="text/javascript">
function baseObject() {
}
baseObject.prototype.setThis=function(x) {
this=x; //line 8
}
var base=new baseObject();
base.setThis("hi!"); alert(base);
</script>
</head>
<body>
</body>
</html>
<html>
<head>
<title>Setting "this"</title>
<script type="text/javascript">
function baseObject() {
}
baseObject.prototype.setThis=function(x) {
this=x; //line 8
}
var base=new baseObject();
base.setThis("hi!"); alert(base);
</script>
</head>
<body>
</body>
</html>