Sidebar

Could you show the syntax to use arrow functions?

0 votes
288 views
asked Apr 27, 2021 by marc-m-6210 (140 points)
I've tried a couple functions and the message says the function is ES6( 'use esversion:6')

1 Answer

0 votes

Although the arrow functions syntax can be used inside of QIE, the syntax validation was not accounting for it. We have updated our JSHint syntax validation in QIE version 5.0.50.  So it should give you better feedback when that version is released.

In short, arrow functions are a compact way to define a javascript function.  Here is an example of how that be used inside of QIE.

// traditional way of defining a function
function oldSchool (a, b) {
   qie.warn("Called oldSchool with " + a + " and " + b);
}

// arrow style syntax for defining the same type of function
var newSchool = (a,b) => qie.warn("Called newSchool with " + a + " and " + b);

// Both are called the same way.
oldSchool("thee", "thine");
newSchool("you", "yours");

Here is an indepth description of how to convert between the traditional syntax and the arrow function syntax in Javascript:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions

answered Apr 28, 2021 by mike-r-7535 (13,830 points)
...