<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>Project-2</title>
<script>
var scope="global scope";
function checkscope(){
var scope="local scope";
function nested(){
var scope="nested scope";
return scope;
}
return nested();
}
document.write("1- "+checkscope()+"|||");
//--------------------------------------
function test(o){
var i=0;
if(typeof o=="object"){
var j=0;
for(var k=0;k<10;k++){
document.write(k);
}
document.write(k);
}
document.write(j+"|||");//undefined !
}
test("object");
//---------------------------------
var a=[1,2,3,4];
for(var i=0;i<a.length;i++)document.write(a[i]);document.write("|||"+a.length+"|||");
delete a[3];
a[4]=5;
for(var i=0;i<a.length;i++)document.write(a[i]);document.write("|||"+a.length+"|||");
//----------------------------------
try{
sadfasdfasd
}catch(ex){document.write("|||ERROR!!!");}
finally{
document.write("|||Kodlamak Guzel...|||");
}
//--------------------------------------------
//Bu özelliği çok kullanışlı.JavaScript cahili olduğum için
//bunu bilmiyordum :) neyse bilmemek ayıp değil öğrenmemek ayıptır...
var book={
"man title":"JavaScript",
'sub-title':"The Definitive Guide (source :) )",
"for" : "all audiences",
author : {
firstname:"David",
surname:"Flanagan"
}
}
var name=book.author.firstname;
var title=book["man title"];
document.write(name+"|||"+title+"|||");
//------------------------------------------------
var customer=[1,2,3,4];
var addr = "";
for(i = 0; i < 4; i++) {
addr += customer["address" + i] + '\n';
}
//-------------------------------------------------
//inheritance
var o={};
o.x=1;
var p=inherit(o);
p.y=2;
var q=inherit(p);
q.z=3;
var s=q.toString();
//-------------------------------------------------
var o = { x: 1 }
o.hasOwnProperty("x");//true
o.hasOwnProperty("y");//false
o.hasOwnProperty("toString");//false
//--------------------------------------------------
function keys(o){
if(typeof o!="object") throw TypeError();
var result=[];
for(var prop in o){
if(o.hasOwnProperty(prop))
result.push(prop);
}
return result;
}
//--------------------------------------------------
//getter && setter
var random={
set octet(n){this.n=n;},
get octet(){return Math.floor(Math.random()*366);}
}
</script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
</body>
</html>
//Çıktımız