What is a difference between an object literal and a class with values in constructor in javascript?
问题 I've been working on end to end test in testcafe and in their documentation I found following solution for Page Model: class Page { constructor () { this.nameInput = Selector('#developer-name'); } } export default new Page(); I've been doing some research and I cannot get my head around why it is not resolved with an object literal: export const Page = { nameInput: Selector('#developer-name'); } What are consequences of using each of them? 回答1: The difference is significant but fundamentally