5 posts tagged with "javascript"

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
Use an interface (Typescript 2.2+) We can extend types in Typescript by using the extends keyword For example we can write: Use an intersection type

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…