Javascript define a function within event handler

How can I write a function within the onclick event of a button What I want to do is something similar to this: <button onclick=”(function(){ console.log(‘some code here’) })”>My button</button> Answers: Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So … Read more

IE does not support arrow(=>)

this is my code: function LoadDate() { document.querySelectorAll(‘[display-date]’).forEach(el => el.innerHTML = getTheDate()); } It is not working on IE because of this arrow (el => ) as I understand from my last question .. how can I convert it to be supported in all browsers? Thanks for your time ^_^ Answers: Thank you for visiting … Read more

Correct use of arrow functions in React

I am using ReactJS with Babel and Webpack and using ES6 as well as the proposed class fields for arrow functions. I understand that arrow functions make things more efficient by not recreating the functions each render similar to how binding in the constructor works. However, I am not 100% sure if I am using them correctly. The following is a simplified section of my code in three different files.