troubleshooting Question

How do I develop and use classes in Javascript?

Avatar of webfullcircle
webfullcircleFlag for United States of America asked on
Web Languages and StandardsJScriptJavaScript
15 Comments1 Solution381 ViewsLast Modified:

I am developing a small library of functions. There may be a need where these functions could potentially interfere with each other so I need to put them into a class which than can be given an instance of.

Question is, How do I do it? And then how do I use the class?
I tried doing something like this but it does not work...
---- in the .js file ----
class JsLib
  public function Func1 ()
  public function Func2 ()
--- in html, the .js is included, then ---
<script type="text/javascript>
function Exec()
   var a = new JsLib();
<a href="javascript:Exec();">test</a>

Open in new window


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 15 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros