How can I add multiple properties for a class in Javascript?

I want to add multiple properties to “Person” class. This instance will be called by getDetails() method. So I easily can pass an array of values to my objects (variable), ex. var john = new Person("John Doe", "32", "Web Developer");.

function Person(name, age, occupation) {
  this.name = name;
  this.age = age;
  this.occupation = occupation;
}
Person.prototype.getDetails = function () {
  return this.name;
  return this.age;
  return this.occupation;
};
var john = new Person("John Doe", "32", "Web Developer");

document
  .getElementById('demo')
  .innerText = john.getDetails();
<h2>JavaScript Class Method</h2>

<p>How to define and use a Class method.</p>

<p id="demo"></p>

Answer

Note that after return all code is unreachable!

So you need to concatenate the properties and combine as a one string like this:

function Person(name, age, occupation) {
  this.name = name;
  this.age = age;
  this.occupation = occupation;
}
Person.prototype.getDetails = function () {
  return this.name + " " + this.age + " " + this.occupation;
};
var john = new Person("John Doe", "32", "Web Developer");

document
  .getElementById('demo')
  .innerText = john.getDetails();
<h2>JavaScript Class Method</h2>

<p>How to define and use a Class method.</p>

<p id="demo"></p>