1

I'm using node.js to run JavaScript in my terminal. When I run the following JavaScript file (testfile.js) in my terminal with the command "node testfile.js", here's what I get:

console.log("meh");

=> meh

So that works fine. But when I make it a function like this:

function sayMeh() {
    console.log("meh");
};

sayMeh;

=> 

I get no result. Why? How can I test JS to see if it works?

2
  • 1
    sayMeh will return function expression, Use parenthesis () after function name to call that function.. Commented Nov 15, 2015 at 2:42
  • @RayonDabre more specifically it will return a reference to the function that is a value you can hand around. Commented Nov 15, 2015 at 12:00

1 Answer 1

5

You need to call the function, not just mention it.

sayMeh();
Sign up to request clarification or add additional context in comments.

1 Comment

Oh, for cryin in the soup... Thank you!!

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.