Developer Console Examples
Learn JS
Try typing the following into the console or use copy/paste.
1 + "1"
0 == ""
0 === ""
obj = { firstname: 'John', lastname: 'Doe', age: 22 };
JSON.stringify(obj, null, 2);
Test Restful API
Try typing the following into the console or use copy/paste. Look at network tab of Developer tools for more details on the request and response.
$.getJSON("student/2.json");
$.ajax({url: "student/2.json", type: "GET"});
$.ajax({url: "student/2.json", type: "POST", data: {firstname: "Joe", lastname: "Doe" } });
Learn DOM and events
Try typing the following into the console or use copy/paste.

//Right-click on blue box and select "Inspect element"
//Go back to developer console and enter $0
//We can interact with elements selected on Elements tab in Console using $0, 1
//Change the color of the box
$0.style.backgroundColor = "green";
//We can see how mouse move events work over the box and where we are scolled in the page
$($0).on("mousemove", function (evt) { console.log('pageX ' + evt.pageX + ' pageY ' + evt.pageY); });
//So, you can see pageX and pageY are based upon 0,0 being the top-left of the unscrolled page.
//If you put the mouse over the box and then use the wheel on the mouse you'll notice the event doesn't trigger even though you are over a different part of the box, let's try and find that event
$("body").on("scroll", function () { console.log("scroll body"); });
$(window).on("scroll", function () { console.log("scroll window"); });
Try out a library
Select2.js is already in the same folder as this HTML file, but hasn't be added to this page. Let's add it to the page and style this drop-down.
`

s = document.createElement("script");
s.src = "select2.js";
document.body.appendChild(s);
l = document.createElement("link");
l.rel = "stylesheet";
l.href = "select2.css";
document.head.appendChild(l);
//Use this
$($0).select2();
//Or
$("#testSelect").select2();
Notes
  • Console retains history of previously entered JS, use up and down arrow.
  • Console supports copy/paste and multiple lines. IE has single-line and multi-line mode, Chrome and Firefox you can use Shift+Enter or paste multiple line code into console from another editor.
  • Intellisense completion using 'tab'. Works in IE11, Chrome and Firefox
  • Expand values of object and arrays directly in console. Works in IE11, Chrome and Firefox
  • If you select a DOM node in the "Elements/Source" tab it will be available in the console as $0. The last thing selected in that tab will be $0, the second to last thing will be $1 and so on. Another way to select an element is to right-click in the browser and select the "Inspect Element" menu item.Works in IE11, Chrome and Firefox
  • For pages with frames, IE11 and Chrome console allow you to select the frame.