Contact!

JavaScript

Posts in this category:

Get the current mouse position from a JavaScript event

Get the current position of the mouse from a JavaScript event

by Gav 24/05/2020

Lets look at how to get the current clientX and clientY position of the mouse pointer from a JavaScript 'mousemove' event.

Multiple values in an Array, creating an inArray function in Javascript

Find single or array of values in JavaScript array using includes

by Gav 20/05/2020

Find out whether a JavaScript array contains single or multiple values by passing an array of values to includes() with the help of some() and every().

Find nearest number in array

Find the closest number in an array JavaScript

by Gav 12/11/2019

Would you like to match the closest number in an array using JavaScript? Find out how to achieve this using both reduce() and sort().

Get the difference JavaScript

Get the difference between 2 numbers JavaScript

by Gav 12/11/2019

Getting the difference between 2 numbers in JavaScript isn't as simple as it sounds. Let's look at 2 methods for reliably returning the difference.

String Interpolation JS, SCSS, SASS

String interpolation in JavaScript, Sass and scss

by Gav 01/11/2019

Use Sass variables inside css variables and strings. Learn how to interpolate strings in JavaScript(es6), Sass and scss.

Valid html check

Valid HTML element tag check: JavaScript

by Gav 31/10/2019

Learn how to check for valid HTML element tags by converting them to string representations with this simple JavaScript function.

eval() alternative

Calling a function using a string: JavaScript

by Gav 29/10/2019

Call a function using a string in JavaScript: a safe alternative to eval().

Web Component

Web Components tutorial: Custom Elements in JavaScript

by Gav 23/10/2019

What are web components? Learn about web components, the shadow DOM, styling and lifecycle callbacks in this JavaScript tutorial series.

forEach loop JavaScript

HTMLCollection forEach loop – Convert object to array: JavaScript

by Gav 17/10/2019

4 ways to convert array-like objects, such as HTMLCollection and NodeList, to JavaScript arrays for access to array methods like the forEach loop.

;