Migrating to modern javascript
In 2015 the new "ES6" version of javascript introduced a many fundamental and routine improvements in the language.
The concept of "modules" allows the packaging up a group of associated functions so that they have their own module scope variables that do not interfere with the standard global variables. NEOSYS may be refactored to take advantage of the protection that this brings and it will allow the introduction of industry standard libraries without those libraries conflicting with NEOSYS scripts. NEOSYS currently does not use any libraries since it was created long before any javascript libraries existed.
On the routine programming side this page will contain a list of the possible improvements in programming style that can be used when adding new code to the NEOSYS javascript code base.
Old | New | Comments |
---|---|---|
for (var acnon=0;acnon<acnos.length;++acnon) {
var acno=acnos[acnon].split(sm)
if (acno[1])
acno=acno[1]
else if (acno[0]) {
//acno="."+acno[1]
acno="."+acno[0]
} else
acno=''
acnos[acnon]=acno
} |
acnos=acnos.map(acno => {
acno=acno.neosyssplit(sm) if (acno[1]) return acno[1] else if (acno[0]) { //acno="."+acno[1] return "."+acno[0] else return '' }) |
|