for web2.0/javascript2007/05/21 08:38

<html>
<head>
<script language=javascript>
function test(argTest)
{
 'x' in argTest ? alert('x = ' + argTest.x) : "";
 'y' in argTest ? alert('y = ' + argTest.y) : "";
 'z' in argTest ? alert('z = ' + argTest.z) : "";
}

function functest() {
 return 'this is from a function';
}

</script>
</head>
<body>
<button onclick="test({x:1, y:'two'});">Test x,y</button><br>
<button onclick="var zarg='z arg'; test({z:zarg});">Test z</button><br>
<button onclick="var f = functest(); test({x:f});">Test function</button><br>
</body>
</html>

Posted by maketalk.net