简体   繁体   中英

Why doesn't node run javascript functions in my terminal or browser?

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?

您需要调用函数,而不仅仅是提及它。

sayMeh();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM