Search notes:
JavaScript: printf in the console
The
console.log()
method has some basic
printf functionality: (
%s
for strings,
%d
for integers,
%f
for floats (doubles?))
<html>
<head>
<meta charset="utf8">
<title>console.log</title>
<script type="text/JavaScript">
function main() {
var str = 'foo bar baz';
var i = 42;
var flt = Math.PI;
console.log('str: %s', str);
console.log('i : %s', i );
console.log('flt: %f', flt);
// var obj = {x: 'eggs', y: 'why', z: {num: 42, question: '?'}};
// console.log('obj: %o', obj);
// console.log('obj: %O', obj);
}
</script>
</head>
<body onload='main()'>
</body>
</html>