Jump to content

code not understood


Recommended Posts

var gameTitle = function(game){}

gameTitle.prototype = {
  create: function(){}
}

It's a JS pattern to add class-like behaviour into a prototypal language, if you know what classes are (in Java, C++ etc for example) then its pretty akin to that. The top function call is a constructor function, the prototype bit adds methods (behaviours) to your class. You should just call this an object as JS doesn't have traditional classes (despite the new class syntax).

The way you're doing it though stamps over any existing methods on the prototype, this is generally bad, sometimes very bad.

Extending the checkout with additional functionality is fine but be careful stamping over it, particularly if you're setting up some sort of inheritance chain.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...