Object property shorthand
JavaScript Property Definitions Shorthand
It applies only when the property name is the same as the name of the variable that stores a value.
To put variables into an object you can do something like that:
Don't do this
import edit from '@salesforce/label/c.Edit';
import save from '@salesforce/label/c.Save';
const labels = {
edit: edit,
save: save
};
export default labels;There is a shorter notation available to achieve the same:
Do this
import edit from '@salesforce/label/c.Edit';
import save from '@salesforce/label/c.Save';
const labels = {
edit,
save
};
export default labels;It applies only when the property name is the same as the name of the variable that stores a value.
Don't do this
showToast(title, message, variant) {
this.dispatchEvent(
new ShowToastEvent({
title: title,
message: message,
variant: variant
})
);
}Do this
showToast(title, message, variant) {
this.dispatchEvent(
new ShowToastEvent({
title,
message,
variant
})
);
}
