22
loading...
This website collects cookies to deliver better user experience
Recognizing JS Events: In UPFRONT, there are many buttons awaiting an action. The action, a "click", is a JavaScript event. This event results in JavaScript doing "work", most accurately in the form of a callback action.
Manipulating the DOM: The Document Object Model, or the DOM, is often changed or updated through events in JavaScript. In UPFRONT, a "clicked" button (the event) may return a change in color, the addition of a new instance on the page, or the rendering of an edit form.
Communicating with the server: After doing the work and manipulating the DOM, the JavaScript application communicates with the server to report the changes made from the event and to the DOM. This finalizes the effect of user-made actions to application's frontend (the browser) and backend (the database).
showTasksButton().addEventListener("click", handleClick)
const handleClick = () => {...}
Functions have been the biggest surprise for me in learning and applying JavaScript. While they resemble methods commonly seen in RoR, they are much more complex and powerful. Functions in JavaScript are first-class data.
This means that a function can be an argument to another function, a function can be the return value of another function, and a function can be set as the value of a variable, to name a few aspects. The extended functionality of JavaScript functions allows for abstraction, DRY code, and overall, a more sophisticated application.