Here is the code.
commLib.commBegin = function (data) {
var returnValue
port.open(error => {
if (error) {
returnValue = [data[0], 'error', error]
console.log('1-1')
} else {
returnValue = [data[0], 'completed']
console.log('1-2')
}
})
console.log('2')
return returnValue
}
I want to print data,
1-1 //or 1-2
2
but, If I execute this.
2
1-1 //or 1-2
I know Javascript is synchronous, but I want to know whether there is no way. And, if there is a way, please teach me.