When to use the word “prototype” in adding new properties to an object in javascript?
问题 I don't understand in JavaScript when to use the word "prototype" vs. using simple "dot" notation without the word "prototype". Can someone look at these code blocks and help me understand when you'd want to use one over the other? with "prototype": function employee(name,jobtitle) { this.name=name; this.jobtitle=jobtitle; } var fred=new employee("Fred Flintstone","Caveman"); employee.prototype.salary=null; fred.salary=20000; console.log(fred.salary); without "prototype": function employee