The biggest reason not to use the 2nd form is that you’ll end up eliminating anything else that existed in the prototype before you assign it. If that isn’t something you’re concerned with there’s no reason not to declare it the way you’ve demonstrated.
More Related Contents:
- Preserving a reference to “this” in JavaScript prototype functions [duplicate]
- How does __proto__ differ from constructor.prototype?
- What’s the purpose of prototype? [duplicate]
- Better way to sum a property value in an array
- Benefits of prototypal inheritance over classical?
- JavaScript: Class.method vs. Class.prototype.method
- prototype based vs. class based inheritance
- Understanding prototypal inheritance in JavaScript
- What does it mean that Javascript is a prototype based language?
- JavaScript instance functions versus prototype functions [duplicate]
- __proto__, when will it be gone? Alternatives?
- Defining prototype methods inside the constructor
- Javascript inheritance: call super-constructor or use prototype chain?
- Is there a good use case for the constructor property in Javascript?
- [[Prototype]] vs prototype: ..what is the difference? (MyCons.__proto__ === MyCons.prototype) equals FALSE
- prototypal inheritance concept in javascript as a prototype based language
- How to dynamically create CSS class in JavaScript and apply?
- Difference between DOMContentLoaded and load events
- ReactJS – Does render get called any time “setState” is called?
- Setting query string using Fetch GET request
- typescript – cloning object
- iOS 8 removed “minimal-ui” viewport property, are there other “soft fullscreen” solutions?
- How to iterate through all attributes in an HTML element?
- In JavaScript, does using await inside a loop block the loop?
- Is true == 1 and false == 0 in JavaScript?
- How target DOM with react useRef in map
- HTML5 restricting input characters
- How can I create unique IDs with JavaScript?
- Generate dynamic css based on variables angular
- Switch case with conditions