how to run javascript in terminal
const { exec } = require("child_process");
exec("ls -la", (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
});
// With node.js installed in windows commandline
C:\Users\Name> node
> console.log("Hello World");
Hello World
undefined
> $ node // now we can execute code in console
> 2 + 4 //our input
6 //output
> .exit // or ctrl + c
Also in JavaScript:
- javascript class static method
- how to find length of array in javascript without using length method
- javascript variable shortcuts
- react replace all line breaks with br
- redirect to url in javascript
- javascript online test
- set headers in express
- javascript get data attribute value
- how to make an alphabet in javascript
- set readonly in javascript
- round to decimal javascript
- onclick inline function react
- copy text on button click in jquery
- react set port
- how to know if a number has a decimal number js
- how to add multiple comment in react
- javascript add minutes to date
- class javascript
- save sort order of jquery sortable
- Convert JS Object to form data Ask Question
- javascript string in multiple lines
- javascript function that console ogs after 3 seconds
- javascript tap and hold
- js for each item in array