6 posts tagged with "javascript"
Setting a variable value as an object key in Javascript: The Simplest Way
In Javascript, you sometimes may find yourself needing to assign an attribute to an object based off the value of another variable. There are currently two ways of doing this: What’s the old way? (Pre ES6) The old way that you used to do this was to make the object…
Sorting an array of objects by a property value in javascript
Sorting using sort() Lets say that you have an array of objects that you wanted to sort by: You can use the sort() method of the Array that uses a callback function. The function takes 2 parameters in the array (commonly called a and b) When the callback function…
How to extend types in Typescript
When working with TypeScript, you’ll frequently encounter scenarios where you need to merge or enhance existing types to craft a new, specialized one. Fortunately, TypeScript makes this process straightforward and user-friendly. To extend a type in Typescript, you have…
Removing empty elements from an array
When dealing with tag inputs from users, I find myself having to make sure they they don’t enter in any blank or empty tags. Then I realized that I needed to find out how to remove undesirable elements not only from the Php side, but also from the Javascript side as…
Remove Anchors from a Url in Javascript
Here is something useful that I discovered in my programming for my personal websites. I needed to strip out the anchor portion of a link and leave the rest of the url intact. For example I wanted: http://jelaniharris.com/I-love-apple-pies#comments To look like: http…
Adding a delay to JQuery Functions
Recently I was working on a few functions that I didn’t want to have activated immediately after hovered over a div. I neededthe functions to activate after a half a second of hovering by the user. To do this I created this this piece of code. Let’s go through line by…