I wanted to "upgrade" my javascript code to the new ES6 standard, so I looked at how the functions are now executed and tested on my global function, which reads like this in the "old" es5
function logMessage(message) { document.getElementById("logs").innerHTML = document.getElementById("logs").innerHTML + `<li class="item-padding"> ${message} </li>` }
now, if I am not mistaken, the correct "conversion" to es6 would be as follows:
logMessage = message => { etc }
But my ESLint tells me that my logMessage is not defined, and I get an error in my console, will I miss something? Should I declare var, let or const before logMessage?
I donβt know if this is important, but I also want to export this function from the One file to the Two file and use the logMessage function in another function in the Two file, is there something I should remember about this
Thanks for any help!
Edit: Thanks to everyone that the answers helped me a lot, the problem has been fixed!
javascript function ecmascript-6 arrow-functions
Nikolai Nowolodski
source share