-1

Do all methods have to be stated after all properties in JavaScript when defining objects in object literal form? I have tried voiding this idea and it seems that all properties stated afterwards are not included.

1 Answers1

0

Do all methods have to be stated after all properties in JavaScript when defining objects in object literal form?

No.

Object properties have a value that is either a primitive or a reference to an object. The order in which they are added, either by a literal or assignment, is irrelevant:

var obj = {
  prop0: 0,
  method0: function(){},
  prop1: 1,
  method1: function(){}    
}
RobG
  • 142,382
  • 31
  • 172
  • 209