1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the documentation of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:FDL$
9 ** GNU Free Documentation License
10 ** Alternatively, this file may be used under the terms of the GNU Free
11 ** Documentation License version 1.3 as published by the Free Software
12 ** Foundation and appearing in the file included in the packaging of
16 ** Alternatively, this file may be used in accordance with the terms
17 ** and conditions contained in a signed written agreement between you
26 ****************************************************************************/
28 \page qtqml-javascript-hostenvironment.html
29 \title JavaScript Host Environment
30 \brief Description of the JavaScript host environment provided by the QML engine
33 QML provides a JavaScript host environment tailored to writing QML applications.
34 This environment is different from the host environment provided by a browser
35 or a server-side JavaScript environment such as Node.js. For example, QML does
36 not provide a \c window object or \c{DOM API} as commonly found in a browser environment.
40 Like a browser or server-side JavaScript environment, the QML runtime implements the
41 \l{ECMA-262}{ECMAScript Language Specification} standard. This provides access to
42 all of the built-in types and functions defined by the standard, such as Object, Array, and Math.
43 The QML runtime implements the 5th edition of the standard, which is the same edition commonly
44 implemented by browsers.
46 The standard ECMAScript built-ins are not explicitly documented in the QML documentation. For more
47 information on their use, please refer to the ECMA-262 5th edition standard or one of the many online
48 JavaScript reference and tutorial sites, such as the \l{W3Schools JavaScript Reference} (JavaScript Objects
49 Reference section). Many sites focus on JavaScript in the browser, so in some cases you may need to double
50 check the specification to determine whether a given function or object is part of standard ECMAScript or
51 specific to the browser environment. In the case of the W3Schools link above, the \c{JavaScript Objects
52 Reference} section generally covers the standard, while the \c{Browser Objects Reference} and \c{HTML DOM
53 Objects Reference} sections are browser specific (and thus not applicable to QML).
55 \section1 Host Objects and Functions
57 The QML JavaScript host environment implements a number of host objects and functions, as
58 detailed in the \l{QML Global Object} documentation.
61 \section1 Native Object Modification
63 QML makes the following modifications to native objects:
66 \li An arg() function is added to the String prototype.
67 \li Locale-aware coversion functions are added to the \l Date and \l Number prototypes.
70 \section1 Restrictions
72 QML implements the following restrictions for JavaScript code:
75 \li JavaScript code cannot modify the global object.
76 \li Global code is run in a reduced scope.
77 \li The value of \c this is undefined in QML in the majority of contexts.
80 See \l {QML JavaScript Restrictions} for more details on these restrictions.