DOM Events with Javascript Question

Hi, this question regards the “DOM Events with Javascript” exercise in “Building Interactive Javascript Websites”.

let sharePhoto = function(event) { = 'none'; 
  + event.timeStamp + ' ms.';

share.onclick = sharePhoto;

In the last line, why can sharePhoto be passed without an argument or parentheses?

Also, why can the last line (share.onclick = sharePhoto;) not be put within another function on its’ own i.e without anonymous functions such as…

let eventAssignment = button => {
  button.onclick = function() {

and not just

let eventAssigment = button => {
  button.onclick = sharePhoto;

Many thanks


We don’t see where this (text) is defined.


It wasn’t relevant to the question but I have removed it anyway. The question is in regards to a syntax question, not the contents of the function.


Copy that.

1 Like