The global object is a pre-defined object that serves as a placeholder for the global
properties and functions of JavaScript. All other predefined objects, functions, and
properties are accessible through the global object.
Parses a String into an integer Number. This function is a short form for the call to parseInt(String, Number) with automatic determination of the radix.
Provides access to the SlotContent object. Available only in ISML
templates that are defined as the Slot's template. For example,
<isprint value="${slotcontent.callout}"> will print out the callout message
of the active Slot.
Provides access to WSDL definition files in a Cartridge's webreferences2
folder. For example, webreferences2.mywebservice loads the
mywebservice.wsdl file and returns an instance of dw.ws.WebReference2.
The WebReference2 instance enables you to access the actual web service
via the WebReference2.getDefaultService() method.
References the module.exports property of the current module. Available only in scripts that were loaded
as CommonJS module using the require(String) function.
Imports all functions from the specified script. Variables are not imported
from the script and must be accessed through helper functions.
The script path has the following syntax: [cartridgename:]scriptname, where
cartridgename identifies a cartridge where the script file is located. If
cartridgename is omitted the script file is loaded from the same cartridge
in which the importing component is located.
Examples:
importScript( 'example.ds' ) imports the script file example.ds from the same cartridge
importScript( 'abc:example.ds' ) imports the script file example.ds from the cartridge 'abc'
This function is a short form for the call to parseInt(String, Number) with automatic determination of the radix.
If the string starts with "0x" or "0X" then the radix is 16. If the string starts with "0" the the radix is 8. In all other cases the radix is 10.
Parses a String into an integer Number.
This function is a short form for the call to parseInt(String, Number) with automatic determination of the radix.
If the string starts with "0x" or "0X" then the radix is 16. In all other cases the radix is 10.
Parameters:
s - the String to parse.
Returns:
Returns the integer as a Number.
API Version:
Available from version 16.1.
ECMAScript 5 compliance: removed support for octal numbers.
The require() function supports loading of modules in JavaScript. The function works similar to the require() function
in CommonJS. The general module loading works the same way, but the exact path lookup is slightly different
and better fits into Demandware concepts. Here are the details for the lookup:
If the module name starts with "./" or "../" then load it relative to the current module. The module can be a file or a directory. A file extension is acknowledged, but not required. If it's a directory a 'package.json' or a 'main' file is expected. If the 'package.json' does not contain a main entry, then default to main file in the directory. Access to parent files can't go beyond the cartridges directory. Access to other cartridges is explicitly allowed.
If the module name starts with "~/" it's a path relative to the current cartridge.
If the module name starts with "*/" try to find the module in all cartridges that are assigned to the current site.
A module with the name "dw" or which starts with "dw/" references Demandware built-in functions and classes. For example var u = require( 'dw/util' );loads the classes in the util package, which can be then used like var h = new u.HashMap();
A module, which doesn't start with "./" or "../" is resolved as top level module.
The module name is used to find a folder in the top cartridge directory, typically a cartridge itself, but it can also be a simple folder.
If nothing is found, the module name is used to look into a special folder called "modules" in the top cartridge directory. That folder can be used by a developer to manage different modules. For example a developer could drop a module like "less.js" just into that folder.
If the require function is used to reference a file then an optional file extension is used to determine the content of the file. Currently
supported are the extensions ordered by priority:
Formats and prints the message using the specified params and returns
the formatted message. The format message is a Java MessageFormat
expression. Printing happens in the script log output.
Parameters:
msg - the message to format.
params - one, or multiple parameters that are used to format the message.