Skip to content

Instantly share code, notes, and snippets.

View YasirGaji's full-sized avatar
◼️
Unconfused Focus

Yasir Gaji YasirGaji

◼️
Unconfused Focus
View GitHub Profile
@YasirGaji
YasirGaji / tafd3.js
Last active February 6, 2022 21:31
This script demonstrates object literals in arrow functions for the "Arrow Functions in Javascript" article by Yasir Gaji
// 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());
@YasirGaji
YasirGaji / clearinterface.js
Created December 26, 2021 16:06
This script is used to illustrate the event listener method in the "The Javascript Events" article by Yasir Gaji
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.