ECMA-262-5 Compliance

Contents

You might wonder what features of JavaScript you can use within your Titanium Mobile applications. As the tests below show, advanced features vary by platform. However, overall Titanium is highly compliant to the ECMA-262 specification: version 3 is fully supported and most of version 5 is also supported. Keep these points in mind:

  • On Android, Titanium includes either the Rhino or V8 interpreter, depending on the build option you select in tiapp.xml.
  • On iOS, Titanium includes the JavaScriptCore engine.
  • Titanium's MobileWeb compliance is not included here because in that case, the user's browser type and version would determine support not Titanium's runtime environment.
  • We're talking here about the JavaScript interpreter that is used to run your Titanium code; we're not talking about JavaScript support within the mobile browsers (e.g. Mobile Safari) on the devices/simulators.

Feature detection

The following table shows the results from running the tests listed at @kangax's ECMAScript 5 compatibility table. These tests detect which JavaScript features are present, but don't necessarily test full functionality or conformance with the ECMA-262/5 spec. Test your code on your target platform(s)!

Test

iOS

Android Rhino

Android V8

Object.create

(tick)

(tick)

(tick)

Object.defineProperty

(tick)

(tick)

(tick)

Object.defineProperties

(tick)

(tick)

(tick)

Object.getPrototypeOf

(tick)

(tick)

(tick)

Object.keys

(tick)

(tick)

(tick)

Object.seal

(tick)

(tick)

(tick)

Object.freeze

(tick)

(tick)

(tick)

Object.preventExtensions

(tick)

(tick)

(tick)

Object.isSealed

(tick)

(tick)

(tick)

Object.isFrozen

(tick)

(tick)

(tick)

Object.isExtensible

(tick)

(tick)

(tick)

Object.getOwnPropertyDescriptor

(tick)

(tick)

(tick)

Object.getOwnPropertyNames

(tick)

(tick)

(tick)

Date.prototype.toISOString

(tick)

(tick)

(tick)

Date.now

(tick)

(tick)

(tick)

Array.isArray

(tick)

(tick)

(tick)

Function.prototype.bind

(error)

(tick)

(tick)

String.prototype.trim

(tick)

(tick)

(tick)

Array.prototype.indexOf

(tick)

(tick)

(tick)

Array.prototype.lastIndexOf

(tick)

(tick)

(tick)

Array.prototype.every

(tick)

(tick)

(tick)

Array.prototype.some

(tick)

(tick)

(tick)

Array.prototype.forEach

(tick)

(tick)

(tick)

Array.prototype.map

(tick)

(tick)

(tick)

Array.prototype.filter

(tick)

(tick)

(tick)

Array.prototype.reduce

(tick)

(tick)

(tick)

Array.prototype.reduceRight

(tick)

(tick)

(tick)

Getter in property initializer

(tick)

(tick)

(tick)

Setter in property initializer

(tick)

(tick)

(tick)

Property access on strings

(tick)

(tick)

(tick)

Reserved words as property names

(tick)

(error)

(tick)

Strict mode

(tick)

(error)

(tick)

Titanium provides its own implementation of the JSON object. So, the original test from @kangax ( JSON – typeof JSON == 'object' ) would always pass. Per the 262-5 spec, the JSON.prototype should exist and should have a Class property equal to "JSON". If we used the native JS object, this code – typeof JSON.prototype != 'undefined' && typeof JSON.prototype.Class == 'JSON' – should resolve to true. But since we use our own implementation, it fails. For that reason, JSON conformance is omitted from the table.

Want to test the results on your own? Download, import, and build this project: https://github.com/skypanther/JSVersion

References

Related Links