Detect mouse right-click with JavaScript

Detect Mouse right-click with JavaScript

In this tutorial, we will see how we can detect mouse right-clicks with Javascript. Click events have a button property associated with it, that allows us to get the exact mouse button. Mousedown and mouseup handlers may need an event to differentiate the clicks because these events trigger on any button. APIs in Javascript allow … Read more

Merge two objects in JavaScript

Merge two objects in JavaScript

In this tutorial, we will learn how to merge two or more JavaScript objects and create a new object that combines the properties of all the objects. To merge objects into a new one containing all the properties of the merged objects, we have two options: Use a spread operator (…) Use the Object.assign() method … Read more

How to remove all non-alphanumeric characters from the String? (w/wo space/hyphen/dashes)

How to remove all non-alphanumeric characters from the String? (w/wo space/hyphen/dashes)

Non-alphanumeric characters are those characters which are not alphabets or numbers. For example characters like exclamation mark(!), commas(,), question mark(?), colon(:), semicolon (;) etc. We will learn two ways to remove non- alphanumeric characters from a string. Both the methods are discussed below. Remove all non-alphanumeric Characters from String (Including Spaces, Hyphen) One way is … Read more