Open In App

Running JavaScript in Console in Microsoft Edge Browser

Last Updated : 30 Oct, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

JavaScript is an important programming language that is mainly developed for web use cases and it plays a vital role in improving the responsiveness and usefulness of websites. On the other hand, Microsoft Edge is a web browser that offers a built-in JavaScript engine for development. So here, we’ll understand the features, benefits, and steps to run Javascript using Microsoft Edge.

Microsoft Edge provides an environment to debug your javascript code. It contains many features which are also listed below, you can perform any possible web-related operations with this tool.

Features Of Microsoft Edge:

  1. It has a console with an interactive environment to write and run JavaScript code in real-time.
  2. You can set breakpoints, check variables, and check step-by-step through code.
  3. Displays errors and warning messages to identify and fix problems in the code.
  4. Can be used to visualize the structure of the DOM.
  5. You can instantly manipulate the DOM elements using the Elements tab.

Steps to run Javascript in the Console of Microsoft Edge :

Step 1: Open Microsoft Edge

ezgifcom-video-to-gif(27)

Step 2: Navigating to the Web Page: Go to the web page on which you want to execute JavaScript or navigate to the desired website.

ezgifcom-video-to-gif(28)

Navigating to GFG page

Step 3: Open Developer Tools

There are 3 methods to open developer tools:

1. Using Right-click :

  1. Right-click anywhere on the web page.
  2. In the context menu, select “Inspect“. This will open the developer tools.

ezgifcom-resize

2. Using Keyboard Shortcut :

  1. Use the keyboard shortcut F12 or Ctrl + Shift + I/J (Cmd + Option + I/J on Mac).

3. Using Menu Option:

  1. Click on the three dots on the top right corner of your browser to open the menu box.
  2. From the menu, select More tools and then Developer tools.

ezgifcom-video-to-gif(30)

Step 4: Go to the Console Tab: In the developer tools , locate the Console tab.

ezgifcom-video-to-gif(31)

Step 5: Write and Execute JavaScript Code: On the console, type JavaScript code. For example :

console.log("Hello, World!");

Then , press Enter to execute. The result of the above code will be displayed on the console.

ezgifcom-video-to-gif(32)

Step 6: Inspect the Elements: The developer tools also allows you to inspect the Document Object Model of the web page. You can select the Elements tab to inspect HTML elements.

ezgifcom-video-to-gif(33)

Example : Here we will explain a simple HTML with Javascript code that is executed through Edge Console to print some message.

Steps :

  1. Create an html file and paste the below code.
  2. Open the file in a browser and press CTRL + SHIFT + I/J to open developer tool.
  3. Inspect the code with elements tab.
  4. Click the button and goto console tab to check the console.log message.

Example Code :

Javascript




var a = 19 
var b = 20
console.log(a+b)


Output :

Running JavaScript in Console

Running JavaScript in Console

Conclusion:

The JavaScript console in Microsoft Edge is a useful tool of development for web developers. It provides an environment for testing, debugging the JavaScript code. Here, we learnt to use the Microscoft edge to execute Javascript code and also manipulate the DOM.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads