JScript Question on includes() statement

Started by kkosienski, December 21, 2022, 14:36:21 PM

Previous topic - Next topic

kkosienski

Im trying to use the includes() statement in an if statement to test for a string pattern in an element name. Any suggestions on how I can accomplish this in jScript?  Here is a first attempt I made but got an error.

$("element").each(function(c) {

  var elementname = c.name;
 
  if(elementname.includes("copy")){
 
     console.log(elementname);
  }
});

kkosienski

I did not see a documented way to use regex or other pattern match within a name selector. I would have tried to solve for it that way.

Phil Beauvoir

I can't see anything wrong there. What is the error message?
If you value and use Archi please consider making a donation. :-)
https://www.archimatetool.com/donate

kkosienski

I am getting the following error.

Script Error at: javax.script.ScriptException, javax.script.ScriptException: TypeError: elementname.includes is not a function in file:/C:/Users/mm45582/AppData/Roaming/Archi4/scripts/examples/Delete%20Unused%20Elements.ajs at line number 18

Phil Beauvoir

Please use the "GraalVM" JavaScript engine in the "Scripting" Preferences.
If you value and use Archi please consider making a donation. :-)
https://www.archimatetool.com/donate

kkosienski

I am only seeing Nashorn ES5 & ES6 as options.

Phil Beauvoir

If you value and use Archi please consider making a donation. :-)
https://www.archimatetool.com/donate

kkosienski

Archi 4.9.1 and Jscript plugin version 0.7.2.202002281033

Phil Beauvoir

The latest version of jArchi is 1.3.1 running under Archi 4.10 available as a binary for supporters of Archi (or build it yourself from source).

BTW, it's jArchi not "Jscript".
If you value and use Archi please consider making a donation. :-)
https://www.archimatetool.com/donate

kkosienski