How to scroll to an element?

React 16.8 +, Functional component Click here for a full demo on StackBlits React 16.3 +, Class component Class component – Ref callback Don’t use String refs. String refs harm performance, aren’t composable, and are on their way out (Aug 2018). string refs have some issues, are considered legacy, and are likely to be removed … Read more

JavaScript function in href vs. onclick

Putting the onclick within the href would offend those who believe strongly in separation of content from behavior/action. The argument is that your html content should remain focused solely on content, not on presentation or behavior. The typical path these days is to use a javascript library (eg. jquery) and create an event handler using … Read more

Blocked script execution in because the document’s frame is sandboxed – Angular application

The error message warns that an Iframe is sand-boxed without a proper privileges Yes, you are clicking in an iFrame. This is an example of a sand-boxed iFrame. If you inspect element on GMail, you will notice iFrames everywhere. The sandbox attribute is not always automatically attached, because the sandbox attribute controls what is allowed. When a … Read more

How do you format a Date/Time in TypeScript?

If you want the time out as well as the date you want Date.toLocaleString(). This was direct from my console: You can then input locale strings and format string to get the precise output you want. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString

Efficient way to implement Priority Queue in Javascript?

Below is what I believe to be a truly efficient version of a PriorityQueue which uses an array-based binary heap (where the root is at index 0, and the children of a node at index i are at indices 2i + 1 and 2i + 2, respectively). This implementation includes the classical priority queue methods like push, peek, pop, and size, as well as convenience methods isEmpty and replace (the latter … Read more