+ 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 :(
12 Respostas
+ 9
You can use babel.min.js for using es6 in older JS engines.
https://code.sololearn.com/W0FsE4Jg5EG5/?ref=app
+ 8
@Ashwani Kumar
Oh It works in my mobile.
Maybe my tablet is troublesome.
bad device :(
Anyway thank you for your help!
+ 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?
+ 7
@Ashwani Kumar
Thanks for your comment
unfortunately console says "Uncaught SyntaxError: Unexpected Identifier(Line 35)
+ 7
@visph
Those features makes code clearer and shorter. That's what I'm looking for. Anyway, I'm gonna install FF.
+ 6
@Thanh Le
Thanks!
I'll search about Babel.
+ 6
Yeah works well for me too.
And just tested on my android device - 7.1.1
It works even without including Babel.
+ 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 )
+ 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
+ 4
@Ashwani Kumar code works well for me ^^
Probably a question of android and/or webview version :(
+ 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 )
+ 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!