5

Have you guys and gals got any tips or hacks for making the most out of the JavaScript intellisense options in Visual Studio 2008?

Visual Studio shows me the "namespaces" and uses the documentation features (<param> and <summary>). I have not been able to get the <return> documentation feature to work though.

Now, that's all well and good. But when I call a privileged function, Visual Studio does not know about it, and thus I get no documentation.

Is there any way I can expose public variables and privileged functions to Visual Studios intellisense functionality, while still creating objects with private members?

0

1 Answer 1

4

Javascript Intellisense is definitely flaky as far as recognizing function members. I've had slightly more success using the prototype paradigm, so that's something you could check out. Often times, though, I find it still won't reliably list functions in the Intellisense.
Edit: As the original poster suggested in the comments below, it's not really possible to get the same "private" functionality in the prototype model. Javascript doesn't have a concept of private members, but you can emulate member privacy with closure by declaring them in the function constructor. The means though that if you have functions that need to access members, they have to be in the constructor too, so they can't be prototypes.
So while using the prototype model may (or may not) give you better VS Intellisense, it's only useful for public functions that hit public members, and can't be used to improve intellisense for private or privileged functions. Private functions you probably don't want intellisense anyway, but privileged you likely would.

Sign up to request clarification or add additional context in comments.

5 Comments

Correct me if I'm wrong, but that pattern doesn't allow for private members. Or does it? If so; could you give me an example?
Javascript itself doesn't really allow for private members. You can emulate member privacy through closure, which means putting private members in the constructor, which means functions needing to access them can't be prototypes. So the short answer is "sortof".
That's what I thought. So the short answer is "no" then? :)
If we agree; could you edit your post to reflect what your comment. That way I can mark this question resolved.
Using an underscore _var for private member has worked for me all along. True that it wouldn't keep some other class from editing it, but it's well documented that you shouldn't.

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.