0

I suppose node.js allows us to test javascript code outside a browser. I am trying to test this function using node.js.

file print.js

var a = {
    someProperty: 1
}

function printObject(){
    process.stdout.write("hello: ",a);
}

When I try to run the above code as node print.js, nothing gets printed on the console. Why?

4
  • 2
    You are not calling the function. Just defining it. Commented Apr 30, 2018 at 5:26
  • 2
    You would have to call the function like printObject(). You have just declared the function Commented Apr 30, 2018 at 5:26
  • thanks. Happy to accept as an answer if one of you could change your comment into an answer. Commented Apr 30, 2018 at 5:27
  • 1
    Also to this answer, you cannot comma-separate output. Commented Apr 30, 2018 at 5:28

1 Answer 1

1

You would have to call the function like printObject(). You have just declared the function

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.