Appendix: JavaScript FAQ

Can I use the standard JavaScript features like prototypes, "this", function semantics, or do I have to use a "restricted JavaScript"?

Yes, the JavaScript runtime environment embedded by the Quantum platform is ECMA 262 compliant. So all the standard JavaScript features are available out of the box. All the custom Functions and Objects defined by the developer have access to standard JavaScript features. Though the JavaScript Objects/Functions created/defined by the Quantum APIs adhere to this specification there are some known limitations that one must be aware of. These limitations mostly arise from the limitations posed by the JavaScript runtime environment when invoking native SDK APIs (defined in a different language). These limitations have been captured under the sections "JavaScript Function Semantics" and "JavaScript Object Semantics".


What are the different JavaScript runtime environments that Quantum platform bundles for each of the Mobile platforms?

Platform Supported Version JavaScript Engine
iOS 4.0 and above JS Core
Android 2.1 and above Google V8 (via NDK)
MobileWeb All ---

Are there any JavaScript constraints or cross platform nuances that I should be aware of when developing on Quantum platform ?

Yes, even though Quantum platform bundles or uses widely used JavaScript runtime environment, there are some JavaScript APIs that don't work consistently across the JavaScript runtime environments. Below are some of the JavaScript operators and semantics that can result in inconsistent experience across runtimes and should be avoided:

  • typeof operator for the Objects created and returned by the Quantum APIs
  • instanceof operator for the Objects created and returned by the Quantum APIs

I like that Quantum now supports JavaScript. Can I pick a JavaScript based 3rd party library and include it in my project codebase ?

Yes, you can integrate any Javascript library which is purely written in Javascript language without any native, browser dependencies.


I see some of the widgets like Form and Image have got a "2" as suffix when creating the widget. For instance, when creating the form we have to say com.kony.ui.Form2. Why do we need to have "2" as suffix for these widgets ?

When drafting the specifications for the JavaScript APIs there was a conscious effort to ensure common cross platform behavior of some of the widgets. We realized that unless we break some backward compatibility the widget behavior cannot be made consistent across platforms. Hence Quantum came with new API definitions for these widgets with the intention to consolidate the cross platform behavior. A version "2" of these widgets was introduced.


So in general is it recommended to use kony.ui.Image2 or kony.ui.Image, should I use the version "2" of the widgets or their original version ?

For better cross platform behavior we recommend you to use the kony.ui.Image2 widget wherever possible. The original version of the widgets have been retained only for backward compatibility.


Can I use Octal literals in my JavaScript Code?

Octal literals should be avoided in JavaScript Code. Numbers prefixed with 0 will be treated as octal numbers by most of the Javascript Engines but some throw an exception. If you want to parse the octal number from a string variable, use parseInt with radix parameter.