1

The following is a Javascript class that I have created.

(function(window){

    function Project(name,description){

    this.name = name;
    this.description = description;

    }

    window.Project = Project;


}(window));

I know to create variables inside the class using the 'this' keyword. But can someone help as how to create an array as member of the class. In this situation I need to create an array variable 'projectMemebers'

4
  • Are you sure about this. I mean when variables are created we use like this.name = name; You sure something like that wont be needed Commented Apr 30, 2012 at 15:34
  • I'm quite sure, yes. The expression [] creates an empty Array instance. Commented Apr 30, 2012 at 15:35
  • @Pointy: +1 for adding this in comments.... Commented Apr 30, 2012 at 15:37
  • I would have liked if you had answered the question. So I could have given the points to you. Who cares about points when you are 80k :-) Commented Apr 30, 2012 at 15:37

1 Answer 1

6
this.projectMemebers = [];

or

this.projectMemebers = new Array();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.