event.originalEvent.clipboardData.getData('Text').match(/[^\d]/))
In the above code I don't understand the originalEvent
, and clipboardData
process. Please explain it to me briefly.
event.originalEvent.clipboardData.getData('Text').match(/[^\d]/))
In the above code I don't understand the originalEvent
, and clipboardData
process. Please explain it to me briefly.
You have posted code that matches a string against a regular expression (short: regex; a general pattern matching syntax). This string has been obtained through some objects and their properties/methods in response to a jquery event. In detail:
event
:
a jquery event object.
originalEvent
:
the underlying javascript event object.
clipboardData
:
this property reveals that the originalevent has been a ClipboardEvent
(more specifically; a paste
event) from the ClipboardAPI. The property returns a DataTransfer
object that contains the typed data from the clipboard.
getData
:
This method of the DataTransfer
object extracts textual data from the clipboard contents.
match
:
This method retrieves all non-digits from the string as an array or returns null if the string contains digits only.
Note
Most of the links refer to the MDN ( Mozilla Developer Network ), an excellent resource for web development. These pages usually contain links to the pertinent standards, most of which are accessible through the w3c web site too.
Consult these resources frequently and thoroughly, even if it takes time ! - they will vastly improve your development skills and actually save you time in the long run!
I have no affiliations with MDN or W3C apart from using the infos and tools they offer.