Ghoul Fool
Ghoul Fool

Reputation: 6949

Class constructor within Photoshop

This should be straight-forward - creating a simple class within ECMA

class Sandwich
{
  constructor(filling)
  {
    this.sandwichname = filling;
  }
}
mysandwich = new Sandwich("Peanut Butter");

Photoshop says Error 9: Illegal used of reserved word 'class' line 1.

Only I'm sure there is a way to create class - just not with this type of construction, if you pardon the pun.

Upvotes: 1

Views: 109

Answers (1)

speciesUnknown
speciesUnknown

Reputation: 1753

You can't use this version of javascript. However, it is possible to emulate the functionality like so:

function Sandwich(filling) {
  this.filling = filling;
}

Sandwich.prototype.someMethod = function() {
  console.log(this.filling);
};

var jelly = new Sandwich("jelly");

jelly.someMethod();

Upvotes: 1

Related Questions