Cannot make my own class

Community Beginner ,
Apr 30, 2020 Apr 30, 2020

Copy link to clipboard

Copied

I am trying to mkae my own class in Adobe Acrobat DC using Javascript, but I keep getting this error 

"Syntax Error: class is a reserved identifier".  Which doesnt make any sense as I am not making a variable called "class" I am defining a class to make objects.

 

Here is my code:

Omaadarani_0-1588261804005.png

 

If anyone can help, please get back ASAP as this is a project for a client and I have a certain number of hours to work on it and get it done.

 

Thanks

 

TOPICS
Acrobat SDK and JavaScript

Views

135

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Apr 30, 2020 Apr 30, 2020
You got it. Need to do it the old fashion. Construtor class and then prototypes. But the end result is exactly the same thing.  Keep in mind that JavaScript is not true OOP, no polymorhpism, no inheritence, etc. Just simple objects.  

Likes

translate

Translate

Translate
Adobe Community Professional ,
Apr 30, 2020 Apr 30, 2020

Copy link to clipboard

Copied

May be that this is not possible in Adobe Acrobat.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 30, 2020 Apr 30, 2020

Copy link to clipboard

Copied

So there is no way to make my own Classes or Objects in Adobe Acrobat?

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 30, 2020 Apr 30, 2020

Copy link to clipboard

Copied

Of course you can create your own object definitions.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 30, 2020 Apr 30, 2020

Copy link to clipboard

Copied

There are no true classes in JavaScript, the "class" defintition is just a shortcut for creating regular javascript objects. The core JS model in the current version of Acrobat doesn't include it.  

But there is nothing stopping you from just creating regular JS objects.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 30, 2020 Apr 30, 2020

Copy link to clipboard

Copied

So what you are saying is that Acrobats JS model doesnt include making JS objects using ES6 classes (like how I am doing right now?). So I would need to start off by making a contructor functions (example for me it would look like fucntion LinkedList() { ...WHatever needed to construct ... } ) then use prototypes for my methods to my object?

 

Sorry if these are quite simple questions, I have worked with classes & objects in JS before but never contstructed them, and I recently did alot of OOP in C++, so the ES6 method made the most sense to me. 

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 30, 2020 Apr 30, 2020

Copy link to clipboard

Copied

You got it. Need to do it the old fashion. Construtor class and then prototypes. But the end result is exactly the same thing.  Keep in mind that JavaScript is not true OOP, no polymorhpism, no inheritence, etc. Just simple objects.

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 01, 2020 May 01, 2020

Copy link to clipboard

Copied

Thank you so much! Very much appreciated!

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines