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);
}
});
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.
I can't see anything wrong there. What is the error message?
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
Please use the "GraalVM" JavaScript engine in the "Scripting" Preferences.
I am only seeing Nashorn ES5 & ES6 as options.
What version of jArchi are you using?
Archi 4.9.1 and Jscript plugin version 0.7.2.202002281033
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".
Thanks for your help on this.