Java programmer here

Hi, im new here, well not programmersheaven, but this board...

im wondering, we can define classes in javascript, correct? Im wondering if its basically the same as java...you have contructors and use 'new' right? So its like java, but its script and theres no types...

also arguments, is this a good prototype
[code]
foo(a,b);
[/code]
we need no types, right? also, if we use objects as types, like
[code]
class stupid{
var a;
}
foo(stupid a){
document.write(a.a);
}
[/code]
Is there inheritence with extends? also are there interfaces? plz tell.

thanx

{2}rIng

Comments

  • [b][red]This message was edited by dolev9 at 2005-8-1 8:50:55[/red][/b][hr]
    no interfaces no new no nothing.

    only variables you do not have to declare what dype,there are basic inheritance and basic funtion things.

    there are objects(you cannot build new objects),properties,methods,events,and collections.

    for informations and examples check this:
    http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/dhtml_node_entry.asp

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56jsoriJScript.asp




    dolev


  • : Hi, im new here, well not programmersheaven, but this board...
    :
    : im wondering, we can define classes in javascript, correct? Im wondering if its basically the same as java...you have contructors and use 'new' right? So its like java, but its script and theres no types...
    :
    : also arguments, is this a good prototype
    : [code]
    : foo(a,b);
    : [/code]
    : we need no types, right? also, if we use objects as types, like
    : [code]
    : class stupid{
    : var a;
    : }
    : foo(stupid a){
    : document.write(a.a);
    : }
    : [/code]
    : Is there inheritence with extends? also are there interfaces? plz tell.
    :
    : thanx
    :
    : {2}rIng
    :

    Hi

    Try This :
    [code]
    function SomeObject() {
    this.F_Caption = "SomeObject";
    this.F_Color = "#FFFF00";
    this.F_BKColor = "#00FF00";
    }

    function SomeObject_SetCaption(Caption) {
    this.F_Caption = Caption;
    }

    function SomeObject_GetCaption() {
    return this.F_Caption;
    }

    function SomeObject_SetColor(Color) {
    this.F_Color = Color;
    }

    function SomeObject_GetColor() {
    return this.F_Color;
    }

    function SomeObject_SetBKColor(BKColor) {
    this.F_BKColor = BKColor;
    }

    function SomeObject_GetBKColor() {
    return this.F_BKColor;
    }

    SomeObject.prototype.SetCaption = SomeObject_SetCaption;
    SomeObject.prototype.GetCaption = SomeObject_GetCaption;
    SomeObject.prototype.SetColor = SomeObject_SetColor;
    SomeObject.prototype.GetColor = SomeObject_GetColor;
    SomeObject.prototype.SetBKColor = SomeObject_SetBKColor;
    SomeObject.prototype.GetBKColor = SomeObject_GetBKColor;

    var SomeVar = new SomeObject();

    SomeVar.SetCaption("SomeText");
    var SomeText = SomeVar.GetCaption();
    SomeVar.SetColor("#CCCCCC");
    var SomeColor = SomeVar.GetColor();
    SomeVar.SetBKColor("#00FF00");
    var SomeBKColor = SomeVar.GetBKColor();
    [/code]

    I hope this help.
    Any thing elsejust ask.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories