//On SyntheticEvent (parameters from props like onClick)
//e.g.
event.stopPropagation()
Here is what the above code is Doing:
1. We’re creating a new function called handleClick.
2. We’re passing handleClick to the
, and we call event.stopPropagation() in handleClick, this stops the bubbling of the event to the parent element.
6. Therefore, the event never reaches the
const now = new Date() // UTC Date String now.toUTCString() // “Sun, 30 May 2021 14:59:15 GMT” // ISO String now.toISOString() // “2021-05-30T14:59:15.449Z” // Unix timestamp Math.floor(now / 1000) // 1622386878 Here is what the above code is Doing: 1. We create a new Date object. 2. We call the toUTCString() method on the Date…
document.addEventListener(“keydown”, (event) => { if (event.code === “Space”) { // Spacebar was pressed, do something } }); // Other keyCodes -> // https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode Here is what the above code is Doing: 1. We’re listening for a keydown event. 2. We’re checking if the key that was pressed was the spacebar. 3. If it was, we’re…
Navbar Home (current) Link Disabled Search Here is what the above code is Doing: 1. We are importing the NgbCollapse directive from the @ng-bootstrap/ng-bootstrap package. 2. We are adding the directive to the div element that wraps the navbar-collapse class. 3. We are adding a button to the navbar that will toggle the collapse. 4….
You need to use client.setActivity() and then use the client.guilds.cache.size value. For example: client.setActivity(`Currently in ${client.guilds.cache.size} servers`); Here is what the above code is Doing: 1. client.setActivity() is a function that sets the activity of the bot. 2. client.guilds.cache.size is a value that returns the amount of servers the bot is in. 3. `Currently in…
var obj = { “column01”: “Coluna 01”, “column02”: “Coluna 02″ } Object.keys(obj).forEach(function(item){ console.log(item + ” = ” + obj[item]) }) for (var property in obj){ console.log(property + ” = ” + obj[property]); } Here is what the above code is Doing: 1. We create an object with two properties. 2. We use Object.keys() to get…
Object.keys(dictionary).length Here is what the above code is Doing: 1. We create a dictionary called dictionary. 2. We add a key called “name” and assign it the value “John”. 3. We add a key called “age” and assign it the value “36”. 4. We add a key called “country” and assign it the value “Norway”….