JS click event notation

Viewed 66

I'm working through some code a previous developer has written and have came across the following notation:

'.js-enter-new-address click'() {}

The code works but I dont understand why. Can anyone point me to any documentation of how this works? as i've not come across js written in this form before. I would usually expect it to be:

$('.js-enter-new-address').on('click', function(event) {}

Update I've noticed this code is part of the following, Please see below:

    const deliveryAddressComponent = Component.create('.checkout-delivery-address', { 
'.js-enter-new-address click'() {},
});
1 Answers

Its part of a javascript object that is send as a parameter of the create function of the Component object.

I don't know what this Component is or does since it's not native js.

Although the definition of the javascript object parameter seems weird it does seem to work as you can see in the snippet below.

var obj =  { 
'.js-enter-new-address click'() {},
}

console.log(obj);

Related