The DOM API, which is provided by the browser to lets JavaScript
interact with the web page, give JavaScript much of its power:
by calling methods provided by
the DOM API, JavaScript code can change anything about 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 command line to try out JavaScript programs and explore the DOM. In Firefox, you can open the console with CTRL-SHIFT-K or under Tools -> Web Developer -> Web Console. In the console you can enter JavaScript code that is then executed (aka evaluated) by the JavaScript engine in the browser.
FOR YOU TO DO:
open the web console and type in the commands below
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"