var Zahl = -17;
var Zahl = -17.2;
var Zahl = -1.72e1;
Zahl
'number'
var str = '123';
str.indexOf('3')
str.charAt(1)
str.substr(1,1)
str.slice(1,2)
str.split('')
<script> var doc = window.document, s = "Hello Welt!", arr = [ typeof s.indexOf("d"), typeof s.indexOf("Welt"), typeof s.match("world"), typeof s.replace("xyz", "THM"), typeof s.replace(/xyz/i, "THM") ]; doc.write( arr.join(" | ") ); </script>
isNaN(x)
isFinite(x)
Number.MAX_VALUE
var x= Number.MAX_VALUE; if (!isFinite(x*2)){ alert("Die Zahl ist nicht zu verarbeiten");}
<script> var x = "42", y1, y2, y3, s = "typeof x = " + typeof x, a = []; y1 = x + 7; a.push(" | y1 = " + y1); y2 = x - 7; a.push(" | y2 = " + y2); y3 = y1 % 3; a.push(" | y3 = " + y3); alert(s + a.join('')); </script>
<script> var arr = [, ("42" == 42), ("42" === 42), ("42" != 42), ("42" !== 42) ]; arr[0] = !arr[5]; arr[5] = !arr[0]; alert(arr.join()); </script>
<script> var arr = [], typ = [], obj = { x: 4711, y: 4712 }; arr[0] = obj.x; typ.push(typeof arr[0]); delete obj.x; arr[1] = obj.x; typ.push(typeof arr[1]); arr[2] = obj.y; typ.push(typeof arr[2]); obj.y = void(0); arr[3] = obj.y; typ.push(typeof arr[3]); alert(arr+'\n'+typ); </script>
<script> var obj = {'u': 'x', '1': 'y' }, arr = [ 'x', 'y' ], a, b, s ; a = [0,1,2].concat(arr); b = [0,1,2].concat(obj); b[0] = a[3]; arr = [ ]; arr.push( b[0] ); arr.push( b[1] ); arr.push( b[2] ); arr.push( b[3].u ); arr.push( b[3]["1"]); window.onload = function() { document.write( arr.join() ); } </script>
function f(a,b) { // Welche Werte haben hier die Parameter? }
<script> var add1 = function (a, b) { return a + b; }, add2 = function (a, b) { var a = Array.prototype.slice.apply(arguments); return a[0] + a[1]; }; function calc(add1, add2) { var r = []; r[0] = add1( 12, 35 ); r[1] = add2.apply(null, [9, 2]); return r; } window.onload = function () { document.getElementById('OUT').innerHTML = calc(add2, add1); } </script> <div id="OUT"></div>
<script> var a=[NaN,0/0,'blah',0,'0',1,1/0,-1/0,Number(5),null,undefined], b=[], c=[], i, s; for (i=0; i < a.length; i +=1 ) { b[i] = "" + a[i]; c[i] = "" + typeof a[i]; } window.onload = function() { s = "a=["+a+'];<br />'; s += 'b=['+b+"];<br />"; s += 'c=['+c+'];<br />'; document.write(s); } </script>
a=[NaN,NaN,blah,0,0,1,Infinity,-Infinity,5,,]; b=[NaN,NaN,blah,0,0,1,Infinity,-Infinity,5,null,undefined]; c=[number,number,string,number,string,number,number,number,number,object,undefined];
isNaN("356t735") liefert true isNaN("345.56") liefert false isNaN("3.4.5") liefert true isNaN("4564") liefert false
<script> var str = 'Hello, world.'; var b1 = /o, w/.test(str); var b2 = str.search(/o, w/) > -1; var b3 = str.match(/o, w/).length > 0; var b4 = str.indexOf('o, w') > -1; window.onload = function() { document.write( b1 +","+ b2 +","+ b3 +","+ b4 ); } </script>