By interacting with the DOM, i.e. by call methods provide by
the DOM API, we can change a webpage.
By interacting with the DOM we can also open new windows
the DOM API, we can change a webpage.
You can write any program in JavaScript and let it execute in
the browser, for example a computer game:
Interactive JavaScript programming using the web console
The web console of the browser provides a convenient way to explore the DOM on a command line. In Firefox, you can open the console with CTRL-SHIFT-K or under Tools -> Web Developer -> Web Console. In the console you can enter pieces of JavaScript code and let these be executed (aka evaluated) by the JavaScript engine inside the browser.
To try it out, open the web console and type the following commands:
1+2*3
Math.sqrt(25) Math is an JavaScript object that
provides a library of mathematical operations. It is built-in to the JavaScript engine running in your web browser. In JavaScript reference documentation for Math you can read all the operations that it provides.
window.location window is the JavaScript object that represent the current browser window. The location property (aka field) of this object is a JavaScript object that represent the location of the window.
window.location.host This returns the domain of the current location as a JavaScript string.
window.location.href This returns the URL of the current location as a JavaScript string.
You can also do assignments to a property like window.location.href, for instance try window.location.href = "http://duckduckgo.com?q=explain%20window.location.href"