"let" JavaScript keyword does not work for old iOS versions

[ This is the translated & modified version from http://cafe.naver.com/fusefactory/366 ]

  • Fuse version 1.8.1 (build 15610)
  • Operating system version: macOS
  • Problem: let keyword (ES6) seems not working well for old iOS versions (e.g., 9).
    Note that it works pretty well on iOS 10, 11, and usual Android phones (what the user tested).
    Is it intentional or a kind of bug, or maybe JS engine might be different for old iOS versions?
  • Tested environment: iPhone 6 simulator device (8.4 and 9.3) => NOT WORKING
  • Example code:
<App>
	<JavaScript>
        var count = 0;
		var data = [ "", "", "", "", ""];
		count = data.length;
  		let MAX  = 6;
        if ( count < MAX ) {
        	debug_log("Count is small.");
        }
        else {
        	debug_log("Count is big!");
        }

        module.exports.count = count;
	</JavaScript>

	<Text Alignment="Center" Value="{count}" FontSize="50" />
</App>

This is not a bug, or anything Fuse-related at all.

Older iOS uses a JS engine that does not fully support ES6 JavaScript, including but not limited to let keyword. One should either write plain ES5 if their app needs to run on older iOS, or use a transpiler if they want to develop in ES6.

I suggest looking into using TypeScript with Fuse which solves the transpiling issue AND offers the possibility to use a strongly typed language.

1 Like

thank you