var f = function(arg) {
if(arg != null){
document.write(arg);
document.write("<br/>");
}else{document.write("<br/>");}
};
var f1 = function() {
f("EQUALITY");
var a = (1 == "1"); // will try to coalesce for comparison
var b = (1 === "1"); // determines type without coalescing
var c = (1 !== "1");
f(a);f(b);f(c);f();
f("TYPEOF");
var d = 1; var d1 = 1.5; var e = "true"; var g = true;
f(typeof d); f(typeof d1); f(typeof e); f(typeof g); f();
f("Null and Undefined");
f("null similar to c# is a variable which doesnt have a value (an object with no reference). Undefined is when a variable has not been defined in the javascript file yet."); f();
f("NUMBER TYPE");
var n1 = 1; var n2 = 1.2; var n3 = 020; var n4 = 0xaaaa; var n5 = 1.34e6;
var n6 = Number.MIN_VALUE; var n7 = Number.MAX_VALUE;
var n8 = Number.POSITIVE_INFINITY; var n9 = Number.NEGATIVE_INFINITY;
var n10 = NaN;
f(n1); f(n2); f("octal " + n3); f("hex " + n4); f(n5); f(n6); f(n7);
f(n8); f(n9); f(n10); f();
f("OBJECT AND ARRAY");
var data = {
name:"abc",
"name with space":"cde",
dowork: function(arg){f(arg);}
};
f(typeof data);f(data.name);f(data['name with space']);
var arr = ["a", 1, data];
f(typeof arr);f(arr);f(arr[2].name);f(arr[2].dowork("code"));
}();
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.