Conditional Operator: ? : Conditional Operator « Operators « JavaScript Tutorial






<html>
<head>
<title>Conditional Operator Demo</title>

<script language="javascript" type="text/javascript">
<!--

confirmVal = confirm("click");
alertStr = confirmVal ? "You clicked OK": "You clicked Cancel";
alert(alertStr);

//-->
</script>

</head>
<body>

<h1>JavaScript Test Page</h1>

</body>
</html>








2.8.Conditional Operator
2.8.1.The Conditional Operator and if Statement
2.8.2.Tenary operator
2.8.3.Conditional Operator: ?
2.8.4.Finding the absolute value