Right after the function declaration, we will call the function and log the result, Here, we will write a simple function that will compute the simple interest, given the principle, time, and rate. Let’s create a JavaScript file simple-interest.js and open it in our IDE (I’m using VSCode), Empty simple-interest.js file in IDE The preferred way to implement some big and complex code is to write it in a JavaScript file. If we wish to write and test some big and complex function, trying it out in the browser console is not a good idea. Running JavaScript files in the browserĪlthough we can run JavaScript directly from the browser console, it’s only suitable for testing small pieces of code. We will also use this console for displaying the logs and errors generated when we run our JavaScript file in the browsers. Let’s write a code to log ‘Hi from Codedamn’ Running JavaScript in the browser’s console Here we can write our JavaScript code, which then will be interpreted by the browser’s JavaScript Engine, and the browser will show the output. This console is called a REPL or Read Evaluate Print Loop. We will see a console window open, Browser console Step 2: On the side panel opened, click on the console option, Click on the console option Step 1: Right-click on the browser window, and from the bottom of the popup window, click on inspect, Right-click on the browser window and select inspect In chrome, to open the developer console, we can follow the following steps, We can open the browser’s developer console to run JavaScript on your browser. But for now, we will stick with Google Chrome. JavaScript only ran on browsers initially. This method is the most basic approach using which we can run JavaScript. We will also look at some online platforms where you can create and run your JavaScript files without setting up a local environment. We can now use JavaScript to make Web applications, Server-side applications, Cross-platform Mobile and Desktop applications, Machine Learning, and much more! Today we will look at various ways how to run JavaScript file. From being a primary scripting language made for the Netscape Navigator to make websites more dynamic and interactive to the multipurpose and the most loved programming language ever. Over the years, JavaScript has evolved so much.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |