#Cannot add to array within method

30 messages · Page 1 of 1 (latest)

dim ridge
#

check what array is, rather than array[1]?

novel dagger
#

if i do ```js
r.on("line", function (text) {
console.log(text)
})

dim ridge
novel dagger
dim ridge
novel dagger
#

its ['line1', 'line'2, 'line3']

dim ridge
#

ummmm thats kinda weird

novel dagger
dim ridge
novel dagger
dim ridge
#

i personally use vscode

#

but idk intellij i never used that

novel dagger
dim ridge
#

or you could use readFileSync if you want it sync

novel dagger
#

is there a way in vscode to show the functions for fs

dim ridge
#
fs.readFile('theFile.txt','utf-8',function(err,data) {
  if (err) throw err;
  console.log(data.split('\n'))
})
novel dagger
dim ridge
novel dagger
dim ridge
#

and now i figured that the original problem is that you didnt put the stuff inside of the callback

dim ridge
#

found an example

const fs = require('fs');

try {
  const data = fs.readFileSync('/Users/joe/test.txt', 'utf8');
  console.log(data);
} catch (err) {
  console.error(err);
}
novel dagger
#

just cause im tryna transfer my code from c# to js for a website and yh

dim ridge
novel dagger
dim ridge