Home Using JavaScript Classes in JQuery
Reply: 0

Using JavaScript Classes in JQuery

Hosway Published in 2017-12-06 00:28:59Z

Just started a course and our homework involves using a JavaScript class for a project. For some reason my constructor function isn't showing up as defined (reference error: blabitty blah isn't defined) and I've got no clue what I'm doing wrong. Here's what my code looks like:

    $(document).ready(() => {
      class Racer {
        constructor(name,id,keyCode,moves) {
          this.name = name;
          this.id = $(id);
          this.keyCode = keyCode;
          this.moves = moves;
      let plane = new Racer("Plane","#racer1",39,0);
    }) // End of document.ready

So what am I doing wrong here? As I said neither "Racer" nor "plane" are showing up as defined.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.29612 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO