Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

Javascript

Javascript

JavaScript is a cross-platform, object-oriented scripting language. JavaScript is a small, lightweight language; it is not useful as a standalone language, but is designed for easy embedding in other products and applications, such as web browsers. Inside a host environment, JavaScript can be connected to the objects of its environment to provide programmatic control over them.

Limitations

  • JavaScript has a concept of objects and classes but no built-in concept of inheritance.
  • Javascript only has a few built-in types (boolean, float, string, object, array) and it converts from one to another quite freely.
  • JavaScript objects (some call them associative arrays) are like maps in a O-O style with map keys of type String.
  • Use the following to find out whether a JavaScript object supports a certain property or function:
    if (typeof (myObj,someProperty) != undefined) {
       ...
    }
    if (myObj instanceof MyObj) {
       ...
    }
    
    Note: The instance instantiated from JSON is always of type Object Array, therefore it does not work well with the "instanceof" operator.

JavaScript Utilities

There are many tools that can assist Javascript development.

Debugging