+ 7

[JavaScript] Template Literals and Arrow Functions

Is there a way to use these things in SoloLearn? 1. Template Literals var b = `abc${a}`; rather than var b = 'abc' + a; https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Template_literals 2. Arrow Functions var func = (x, y) => { return x + y; }; rather than var func = function(x, y) { return x + y; }; https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions I really wanna use these but SoloLearn Code Playground seems to occur SyntaxError :(

11th May 2017, 12:41 PM
김정제(Legacy)
김정제(Legacy) - avatar
12 Answers
+ 9
You can use babel.min.js for using es6 in older JS engines. https://code.sololearn.com/W0FsE4Jg5EG5/?ref=app
11th May 2017, 1:49 PM
Ashwani Kumar
Ashwani Kumar - avatar
+ 8
@Ashwani Kumar Oh It works in my mobile. Maybe my tablet is troublesome. bad device :( Anyway thank you for your help!
11th May 2017, 10:26 PM
김정제(Legacy)
김정제(Legacy) - avatar
+ 7
@visph thank you for your reply :) I always code with my tablet(kind of android but a bit big). So Is it hard for me to use those things with my tablet?
11th May 2017, 1:17 PM
김정제(Legacy)
김정제(Legacy) - avatar
+ 7
@Ashwani Kumar Thanks for your comment unfortunately console says "Uncaught SyntaxError: Unexpected Identifier(Line 35)
11th May 2017, 2:31 PM
김정제(Legacy)
김정제(Legacy) - avatar
+ 7
@visph Those features makes code clearer and shorter. That's what I'm looking for. Anyway, I'm gonna install FF.
11th May 2017, 2:35 PM
김정제(Legacy)
김정제(Legacy) - avatar
+ 6
@Thanh Le Thanks! I'll search about Babel.
11th May 2017, 1:19 PM
김정제(Legacy)
김정제(Legacy) - avatar
+ 6
Yeah works well for me too. And just tested on my android device - 7.1.1 It works even without including Babel.
11th May 2017, 3:08 PM
Ashwani Kumar
Ashwani Kumar - avatar
+ 4
You can probably ( even surely ^^ ) use these 'advanced' JS feature by using website version of code playground, opened in Firefox web browser... Maybe others desktop browsers will support that also: you have to try ( or look in the MDN ressources the compatibility tables ) ^^ On mobile browsers, I don't have really idea, but on app', the android webview is used, and could not support that... actually ;) in addition to eventual sololearn limitations ( as the console bypass, or some JS object not authorized -- I don't remember which :P )
11th May 2017, 12:50 PM
visph
visph - avatar
+ 4
You can try to install mobile version of Firefox, and use it to access code playground ( but better is to verify before on MDN if those features are supported also in the mobile version -- some advanced features are even only available in Firefox developers edition / nightly build ^^ ). Anyway, these advanced features are really cool, but while they aren't widely supported, they're not really useful, except in special case where user browsers are known :P
11th May 2017, 1:23 PM
visph
visph - avatar
+ 4
@Ashwani Kumar code works well for me ^^ Probably a question of android and/or webview version :(
11th May 2017, 2:38 PM
visph
visph - avatar
+ 4
@Ashwani Kumar: You're right... I haven't tested without :P Code works well for me also without Babel ^^ ( android 6.0 - webview 57.0.2987.132 )
11th May 2017, 3:23 PM
visph
visph - avatar
+ 2
Unfortunately you can't. :( I think the JS engine is a little bit out-dated on sololearn. But you can use a transpiler like Babel that converts your ES6 syntax into ES5 syntax. Then it will also work on sololearn's playground. Good luck!
11th May 2017, 12:50 PM
Thanh Le
Thanh Le - avatar