This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// OBJECT LITERAL WITH ARROW FUNCTION EXPRESSION. Undefined result | |
const obj = () => { name: 'Yasir Gaji' } | |
console.log(obj()); | |
// OBJECT LITERAL WITH ARROW FUNCTION EXPRESSION. Success result | |
const ect = () => ({ | |
name: 'Yasir Gaji', | |
age: 19, | |
}); | |
console.log(ect()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.querySelector('.clear-form').addEventListener('click', clearForm); // Here we selected the "clear-form" class from the html collection and added an event listener to it, which takes in 2 parameters the click event and the named function "clearForm". | |
function clearForm(e) { | |
document.querySelector('.form-area').innerHTML = `<h4>Form Cleared!</h4>`; // This selects the "form-area" class from the html collection and replaces the innerHTML with the text "Form Cleared!" | |
e.preventdefault(); | |
}; // Here the named function "clearForm" clears the form, we also passed the parameter "e" which serves as the "event object" later on declared using the "preventdefault()" method to stop the default behaviour of the event listener. |