I have to convert our scripting engine from Python to JavaScript (backend switching to Go and they do not want to use Iron Python) and trying to recreate all the shortcuts conditions we use in Python. I have a team of scripters who just work with simple expressions and do not dive deep into the language. I want to give them as much similarity as possible and one of the conditions we use in python is checking an array for an object and if it matches, assign this object back to the “match” object. Then match object can then be used for further conditions. If this possible in JS?
if any((match := candidate) in comment.body for candidate in candidates):
print(match)
I tried this in JS, but I cannot assign a value to “found” in the expression. Does anyone know a trick to assign a value to “found”
const array1 = [5, 12, 8, 130, 44];
const found = ""
if (found = array1.find((element) => element > 10));
if (element = 12){
console.log(element)
}
2