Javascript Special Operators

Operator Description
(?:) Conditional Operator
typeof Returns the type of object
instanceof Returns true if an object is an instance of an object type

 

JavaScript Special Operators Example:

<html>
<head>
<script type="text/javascript">
var a = 10;
var b = 20;
var c = 10;
var d = "String";
var linebreak = "<br />";
document.write ("((a > b) ? 100 : 200) => ");
result = (a > b) ? 100 : 200;
document.write(result);
document.write(linebreak);
document.write ("((a < b) ? 100 : 200) => ");
result = (a < b) ? 100 : 200;
document.write(result);
document.write(linebreak);
result = (typeof c == "string" ? "C is String" : "D is Numeric");
document.write("Result => ");
document.write(result);
document.write(linebreak);
result = (typeof d == "string" ? "C is String" : "C is Numeric");
document.write("Result => ");
document.write(result);
document.write(linebreak);
</script>
</head>
<body>
</body>
</html>

Try it:

JS Bin on jsbin.com

Please follow and like us:
Content Protection by DMCA.com