├── README.md ├── ders01.js ├── ders02.js ├── ders03.js ├── ders04.js ├── ders05.js ├── ders06.js ├── ders07.js ├── ders08.js ├── ders09.js ├── ders10.js ├── ders11.js └── index.html /README.md: -------------------------------------------------------------------------------- 1 | "# JSComplex" 2 | -------------------------------------------------------------------------------- /ders01.js: -------------------------------------------------------------------------------- 1 | // VAR - LET - CONST 2 | 3 | /* let age; 4 | console.log(age); 5 | 6 | age = 42; 7 | console.log(age); 8 | 9 | const name = "Arin"; 10 | 11 | console.log(name); */ 12 | 13 | // name = "Elis"; 14 | 15 | /* let name = "Arin"; 16 | console.log(name); 17 | 18 | name = "Elis"; 19 | console.log(name); */ 20 | 21 | /* let str = ""; 22 | 23 | for ( let i =0; i<10; i++) { 24 | str = str.concat(i); 25 | console.log(str); 26 | } */ 27 | 28 | /* const myArr = [1, 2, 3]; 29 | console.log(myArr); 30 | myArr.pop(); 31 | console.log(myArr); */ 32 | 33 | /* const student = { 34 | name: "Arin", 35 | age:5 36 | } 37 | 38 | console.log(student); 39 | 40 | Object.freeze(student); 41 | 42 | student.name = "Elis"; 43 | console.log(student); */ 44 | 45 | /* student = { 46 | name: "Elis", 47 | age:5 48 | } 49 | */ 50 | 51 | /* var age = 40; 52 | console.log(age); 53 | 54 | age = 42; 55 | console.log(age) */ 56 | 57 | // VAR --> global scope / functional scope 58 | 59 | /* var x = 1; 60 | console.log(x); 61 | 62 | if (x === 1 ) { 63 | var x = 10; 64 | console.log(x) 65 | } 66 | 67 | console.log(x) */ 68 | 69 | // LET --> block scope 70 | 71 | /* let y = 1; 72 | console.log(y); 73 | 74 | if (y === 1 ) { 75 | let y = 10; 76 | console.log(y) 77 | } 78 | 79 | console.log(y) */ 80 | 81 | /* const x = 10; 82 | console.log(window.x); */ 83 | 84 | // HOISTING 85 | 86 | // var x; 87 | 88 | /* console.log(x); 89 | 90 | var x = 10; 91 | 92 | console.log(x); */ 93 | 94 | // let y; XXXXX 95 | 96 | /* const y = 102; 97 | console.log(y); 98 | */ 99 | -------------------------------------------------------------------------------- /ders02.js: -------------------------------------------------------------------------------- 1 | // FONKSIYONLAR 2 | 3 | //**** */ Function Declarion // Statement 4 | 5 | /* function square(num) { // Parametre 6 | return (num * num); 7 | } 8 | 9 | square(5) // Arguman */ 10 | 11 | /* square(5); 12 | console.log(square(5)); */ 13 | 14 | // console.log(square(3)); () ---> Invoke 15 | 16 | // Function declaration --> HOISTED 17 | 18 | 19 | //**** */ Function Expression 20 | 21 | /* const square = function (num) { 22 | return (num * num); 23 | } */ 24 | 25 | // Func name is optional 26 | /* 27 | console.log(square); 28 | console.log(square(5)); */ 29 | 30 | // FIRST - CLASS FUNCTIONS 31 | 32 | /* const myArr = [6, "Arin", function() {console.log("Array Element");} ] 33 | 34 | myArr[2](); 35 | 36 | const myObj = { 37 | age: 5, 38 | name: "Arin", 39 | func: function() { console.log("Object Element"); } 40 | }; 41 | 42 | myObj.func(); 43 | 44 | console.log(20 + (function() {return 10; })() ) // IIFE */ 45 | 46 | /* console.log(square); 47 | square(5); */ 48 | 49 | /* const square = function (num) { 50 | return (num * num); 51 | } */ 52 | 53 | // Function Expression is not HOISTED 54 | // Function Expression can be anonymous 55 | 56 | // FIRST - CLASS FUNCTIONS DEVAM 57 | 58 | /* const addFive = function(num, func) { 59 | console.log(num + func()); 60 | } 61 | 62 | addFive(10, function() { return 5;}) */ 63 | 64 | /* const myFunc = function (num) { 65 | return function toDouble() { 66 | console.log(num * 2); 67 | } 68 | } */ 69 | 70 | /* myFunc(7)(); */ 71 | 72 | /* const result = myFunc(7); 73 | 74 | result(); */ 75 | 76 | // IIFE 77 | // Immediately Invocable Function Expression 78 | 79 | /* (function() { 80 | console.log(5 + 12); 81 | })(); */ 82 | 83 | // console.log(sum); 84 | 85 | /* sum(); 86 | console.log(sum); */ 87 | 88 | function square(num1, num2) { 89 | return (num1 * num2); 90 | } 91 | 92 | console.log(square.length); 93 | -------------------------------------------------------------------------------- /ders03.js: -------------------------------------------------------------------------------- 1 | // OBJECTS 2 | 3 | // property -- method: Bir nesne ile iliskili func 4 | 5 | /* const person = { 6 | 7 | name: "John", 8 | surname: "Doe", 9 | age: 40, 10 | languages: ["Turkish", "English", "Spanish"], 11 | fullName: function() { 12 | return this.name + " " + this.surname 13 | }, 14 | address: { 15 | city: "Balıkesir", 16 | district: "Akçay" 17 | } 18 | 19 | } */ 20 | 21 | // Object Literal 22 | 23 | /* const person = { 24 | name: 'John', 25 | surname: 'Doe', 26 | age: 40, 27 | fullName: function() { 28 | return this.name + " " + this.surname 29 | } 30 | } 31 | 32 | console.log(person); 33 | 34 | // dot Notation 35 | 36 | console.log(person.name); 37 | console.log(person.age); 38 | console.log(person.fullName()); 39 | 40 | person.job = "Student"; 41 | 42 | console.log(person); 43 | console.log(person.job); 44 | 45 | // bracket Notation 46 | 47 | console.log(person['name']); 48 | console.log(person['age']); 49 | console.log(person['fullName']()); 50 | console.log(person['na' + 'me']) // 'na' + 'me' ---> 'name' */ 51 | 52 | 53 | /* const person = { 54 | name: 'John', 55 | surname: 'Doe', 56 | age: 40, 57 | fullName: function() { 58 | return this.name + " " + this.surname 59 | } 60 | } 61 | 62 | const arin = {----} 63 | 64 | person.address = {}; 65 | 66 | console.log(person); 67 | 68 | person.address.city = "Balıkesir"; 69 | 70 | console.log(person); */ 71 | 72 | /* const person = { 73 | name: 'John', 74 | surname: 'Doe', 75 | age: 40, 76 | fullName: function() { 77 | return this.name + " " + this.surname 78 | } 79 | } */ 80 | 81 | // CONSTRUCTOR ---> YAPICI 82 | 83 | 84 | /* function Person(name, surname, age) { 85 | const obj = {}; 86 | obj.name = name; 87 | obj.surname = surname; 88 | obj.age = age; 89 | obj.fullName = function() { 90 | return obj.name + " " + obj.surname 91 | } 92 | 93 | return obj; 94 | const person2 = new Person("Ricardo", "Quaresma", 38); 95 | console.log(person2); 96 | 97 | 98 | } */ 99 | 100 | /* function Person(name, surname, age) { 101 | 102 | this.name = name; 103 | this.surname = surname; 104 | this.age = age; 105 | this.fullName = function() { 106 | return this.name + " " + this.surname 107 | } 108 | } */ 109 | 110 | 111 | /* const person1 = new Person("John", "Doe", 40); 112 | const person2 = new Person("Ricardo", "Quaresma", 38); */ 113 | 114 | /* const person1 = new Person("John", "Doe", 40); 115 | console.log(person1) 116 | console.log(person1.fullName()); 117 | 118 | const person2 = new Person("Ricardo", "Quaresma", 38); 119 | console.log(person2) 120 | console.log(person2.fullName()); */ 121 | 122 | 123 | // Object Constructor 124 | 125 | /* const person1 = new Object(); 126 | person1.name = 'John'; 127 | person1.surname = 'Doe'; 128 | person1.age = 40; 129 | person1.fullName = function() { 130 | console.log(this); 131 | return this.name + " " + this.surname; 132 | } 133 | 134 | console.log(person1); 135 | console.log(person1.age); 136 | console.log(person1.fullName()); */ 137 | 138 | // Object.create() ile nesne olusturmak 139 | 140 | /* const person = { 141 | name: 'John', 142 | surname: 'Doe', 143 | age: 40, 144 | fullName: function() { 145 | return this.name + " " + this.surname 146 | } 147 | } 148 | 149 | console.log(person); 150 | 151 | const arin = Object.create(person); 152 | arin.name = 'Arin'; 153 | arin.surname = 'Software'; 154 | arin.age = 5; 155 | 156 | console.log(arin); 157 | console.log(arin.fullName()); */ -------------------------------------------------------------------------------- /ders04.js: -------------------------------------------------------------------------------- 1 | // OBJECTS - Part II 2 | 3 | /* const person = { 4 | name: 'John', 5 | surname: 'Doe', 6 | age: 40, 7 | fullName: function() { 8 | return this.name + " " + this.surname 9 | } 10 | } 11 | 12 | console.log(person); 13 | console.log(person.name); 14 | console.log(person.fullName()); 15 | //console.log(person.fullName2()); 16 | //console.log(person.job); 17 | console.log(person.toString()); 18 | console.log(person.hasOwnProperty("name")); */ 19 | 20 | // OBJECT + name, surname, age, fullName() ----> person 21 | 22 | /* const myObj = {}; 23 | console.log(myObj); 24 | console.log(myObj.toString()); */ 25 | 26 | // OBJECT ---> myObj 27 | 28 | /* function Person(name, surname, age) { 29 | 30 | this.name = name; 31 | this.surname = surname; 32 | this.age = age; 33 | this.fullName = function() { 34 | return this.name + " " + this.surname 35 | } 36 | } */ 37 | 38 | /* const arin = new Person("Arin", "Çekiç", 6); 39 | console.log(arin); */ 40 | 41 | // OBJECT + name, surname, age, fullName() ----> Person ----> arin 42 | 43 | /* console.log(arin.toString()); 44 | console.log(arin.hasOwnProperty("age")); 45 | console.log(arin.__proto__); 46 | */ 47 | /* const elis = new Person("Elis", "Çekiç", 4); 48 | console.log(elis); 49 | elis.job = "Child"; 50 | console.log(elis); 51 | console.log(elis.toString()); */ 52 | 53 | // OBJECT + name, surname, age, fullName() ----> Person + job ----> elis 54 | 55 | /* elis.toString = function() { 56 | return "ELISSSSS"; 57 | } 58 | 59 | console.log(elis.toString()); */ 60 | 61 | /* function Person(name, age) { 62 | 63 | this.name = name; 64 | this.age = age; 65 | } 66 | 67 | Person.prototype.fullName = function() { 68 | return this.name + " " + this.surname 69 | } 70 | 71 | Person.prototype.surname = "Çekiç"; 72 | 73 | const elis = new Person("Elis", 4); 74 | 75 | const arin = new Person("Arin", 6); 76 | 77 | console.log(elis); 78 | console.log(arin); */ 79 | 80 | 81 | const person = { 82 | name: 'XXXXXXXX', 83 | surname: 'XXXXXX', 84 | age: 0, 85 | fullName: function() { 86 | return this.name + " " + this.surname 87 | } 88 | } 89 | 90 | const arin = Object.create(person); 91 | console.log(arin); 92 | console.log(arin.name); 93 | 94 | arin.name = "Arin"; 95 | 96 | console.log(arin); 97 | 98 | console.log(arin.age); 99 | 100 | arin.age = 6; 101 | 102 | console.log(arin.age); 103 | 104 | console.log(arin); 105 | 106 | console.log(arin.hasOwnProperty("age")); 107 | console.log(arin.hasOwnProperty("surname")); 108 | 109 | console.log("surname" in arin); 110 | 111 | -------------------------------------------------------------------------------- /ders05.js: -------------------------------------------------------------------------------- 1 | // NEW OBJECT SYNTAX 2 | 3 | //1 - Shorthand Properties 4 | 5 | /* let name = 'arin', age = 5; */ 6 | 7 | /* const myObj = { 8 | name: name, 9 | age: age 10 | } */ 11 | 12 | /* const myObj = { 13 | name, 14 | age 15 | } 16 | 17 | console.log(myObj.name); 18 | console.log(myObj.age); */ 19 | 20 | //2 - Computed Property Names 21 | 22 | /* let prop1 = 'name'; 23 | 24 | let myObj = {} 25 | 26 | myObj[prop1] = 'arin' 27 | 28 | console.log(myObj); */ 29 | 30 | /* let prop1 = 'name'; 31 | 32 | let myObj = { 33 | [prop1]: 'arin' 34 | } 35 | 36 | console.log(myObj); */ 37 | 38 | 39 | //3 - Short Method Syntax 40 | 41 | /* const person = { 42 | name: 'John', 43 | surname: 'Doe', 44 | age: 40, 45 | fullName: function() { 46 | return this.name + " " + this.surname 47 | } 48 | } */ 49 | 50 | /* const person = { 51 | name: 'John', 52 | surname: 'Doe', 53 | age: 40, 54 | fullName() { 55 | return this.name + " " + this.surname 56 | } 57 | } */ 58 | 59 | /* console.log(person.fullName()); */ 60 | 61 | //4 - Object Destructuring 62 | 63 | /* const person = { 64 | name: 'John', 65 | surname: 'Doe', 66 | age: 40, 67 | fullName() { 68 | return this.name + " " + this.surname 69 | } 70 | } */ 71 | 72 | /* let myVar1 = person.name; 73 | console.log(myVar1); 74 | 75 | let myVar2 = person.age; 76 | console.log(myVar2); */ 77 | 78 | /* let { name: myVar1, age:myVar2 } = person; 79 | console.log(myVar1); 80 | console.log(myVar2); */ 81 | 82 | /* let { name: name, age: age } = person; 83 | console.log(name); 84 | console.log(age); */ 85 | 86 | /* let { name, age } = person; 87 | console.log(name); 88 | console.log(age); */ 89 | 90 | /* const books = [ 91 | { 92 | title: "Kırmızı Pazartesi", 93 | author: "Haruki Murakami", 94 | pageNum: 296, 95 | imageURL: "https://i.idefix.com/cache/600x600-0/originals/0000000064101-1.jpg", 96 | topic: "1968-1970 yılları arasında geçen olaylar, o günün toplumsal gerçeklerini de satırlara taşıyor. Ama romanın odağında bu toplumsal olaylar değil üçlü bir aşk var. Gençliğin rüzgârıyla hareketlenen İmkânsızın Şarkısını ölümle erken karşılaşan gençlerin hayatı yönlendiriyor. Hiçbir şeyin önem taşımadığı, amaçsızlığın ağır bastığı, özgür seksin kol gezdiği bir öğrenci hayatı... Ama diğer yanda da yoğun duygular var... İmkânsız aşklar, imkânsız şarkılar söyleten. Hemen hemen her Japon gencinin okuduğu roman anayurdu dışında da çok kişi tarafından sahipleniliyor." 97 | }, 98 | { 99 | title: "Şeker Portakalı", 100 | author: "Jose Muro de Vasconselos", 101 | pageNum: 200, 102 | imageURL: "https://i.idefix.com/cache/600x600-0/originals/0000000064031-1.jpg", 103 | topic: "İrlandalı yazar Bram Stoker’ın, iki taraf arasındaki bu irade ve güç çatışmasını işlediği ve korku edebiyatının başyapıtlarından biri sayılan Dracula, yayımlanmasının üzerinden yüz yılı aşkın süre geçmesine karşın, bugün de aynı ilgiyle okunuyor." 104 | }, 105 | { 106 | title: "En Uzun Yüzyıl", 107 | author: "İlber Ortaylı", 108 | pageNum: 296, 109 | imageURL: "https://i.idefix.com/cache/600x600-0/originals/0001744876001-1.jpg", 110 | topic: "1968-1970 yılları arasında geçen olaylar, o günün toplumsal gerçeklerini de satırlara taşıyor. Ama romanın odağında bu toplumsal olaylar değil üçlü bir aşk var. Gençliğin rüzgârıyla hareketlenen İmkânsızın Şarkısını ölümle erken karşılaşan gençlerin hayatı yönlendiriyor. Hiçbir şeyin önem taşımadığı, amaçsızlığın ağır bastığı, özgür seksin kol gezdiği bir öğrenci hayatı... Ama diğer yanda da yoğun duygular var... İmkânsız aşklar, imkânsız şarkılar söyleten. Hemen hemen her Japon gencinin okuduğu roman anayurdu dışında da çok kişi tarafından sahipleniliyor." 111 | }, 112 | { 113 | title: "Dracula", 114 | author: "Bram Stoker", 115 | pageNum: 200, 116 | imageURL: "https://i.idefix.com/cache/600x600-0/originals/0001828853001-1.jpg", 117 | topic: "İrlandalı yazar Bram Stoker’ın, iki taraf arasındaki bu irade ve güç çatışmasını işlediği ve korku edebiyatının başyapıtlarından biri sayılan Dracula, yayımlanmasının üzerinden yüz yılı aşkın süre geçmesine karşın, bugün de aynı ilgiyle okunuyor." 118 | }, 119 | { 120 | title: "Karamazov Kardeşler", 121 | author: "Fyodor Mihayloviç Dostoyevski", 122 | pageNum: 200, 123 | imageURL: "https://i.idefix.com/cache/600x600-0/originals/0001803800001-1.jpg", 124 | topic: "İrlandalı yazar Bram Stoker’ın, iki taraf arasındaki bu irade ve güç çatışmasını işlediği ve korku edebiyatının başyapıtlarından biri sayılan Dracula, yayımlanmasının üzerinden yüz yılı aşkın süre geçmesine karşın, bugün de aynı ilgiyle okunuyor." 125 | }, 126 | { 127 | title: "Sultanın Korsanları", 128 | author: "Emrah Safa Gürcan", 129 | pageNum: 296, 130 | imageURL: "https://i.idefix.com/cache/600x600-0/originals/0001780787001-1.jpg", 131 | topic: "1968-1970 yılları arasında geçen olaylar, o günün toplumsal gerçeklerini de satırlara taşıyor. Ama romanın odağında bu toplumsal olaylar değil üçlü bir aşk var. Gençliğin rüzgârıyla hareketlenen İmkânsızın Şarkısını ölümle erken karşılaşan gençlerin hayatı yönlendiriyor. Hiçbir şeyin önem taşımadığı, amaçsızlığın ağır bastığı, özgür seksin kol gezdiği bir öğrenci hayatı... Ama diğer yanda da yoğun duygular var... İmkânsız aşklar, imkânsız şarkılar söyleten. Hemen hemen her Japon gencinin okuduğu roman anayurdu dışında da çok kişi tarafından sahipleniliyor." 132 | } 133 | 134 | ] 135 | 136 | 137 | for (const {title, author, pageNum} of books) { 138 | console.log(title + ': ' + author + ': ' + pageNum); 139 | } 140 | */ 141 | 142 | 143 | 144 | 145 | 146 | //5 - Spread Operator in Object Literals (...) 147 | 148 | /* const person = { 149 | name: 'John', 150 | surname: 'Doe', 151 | age: 40, 152 | fullName() { 153 | return this.name + " " + this.surname 154 | } 155 | } 156 | 157 | const person2 = {...person}; 158 | 159 | console.log(person2); */ 160 | 161 | /* const myObj1 = { 162 | name: 'arin', 163 | age: 6 164 | } 165 | 166 | const myObj2 = { 167 | job: 'student', 168 | gender: 'female' 169 | } 170 | 171 | const arin = {...myObj1, school: 'Zehra Baysal', ...myObj2}; 172 | 173 | console.log(arin); */ 174 | 175 | 176 | //6 - REST Operator in Object Literals 177 | 178 | 179 | /* const person = { 180 | name: 'John', 181 | surname: 'Doe', 182 | age: 40, 183 | fullName() { 184 | return this.name + " " + this.surname 185 | } 186 | } */ 187 | 188 | /* const {name, surname, age} = person; 189 | 190 | console.log(name); */ 191 | 192 | /* const {name, ...rest} = person; 193 | 194 | console.log(name); 195 | 196 | console.log(rest); */ 197 | 198 | //7 - Object Values - Object Entries 199 | 200 | /* const person = { 201 | name: 'John', 202 | surname: 'Doe', 203 | age: 40, 204 | fullName() { 205 | return this.name + " " + this.surname 206 | } 207 | } 208 | 209 | console.log(Object.keys(person)); 210 | console.log(Object.values(person)); 211 | console.log(Object.entries(person)); */ -------------------------------------------------------------------------------- /ders06.js: -------------------------------------------------------------------------------- 1 | // JS CLASSES 2 | 3 | /*constructor function 4 | function Person(name, surname, age) { 5 | 6 | this.name = name; 7 | this.surname = surname; 8 | this.age = age; 9 | this.fullName = fullName; 10 | } 11 | */ 12 | 13 | /* function fullName() { 14 | return this.name + " " + this.surname 15 | } */ 16 | 17 | /* Person.prototype.fullName = function() { 18 | return this.name + " " + this.surname 19 | } 20 | 21 | Person.prototype.friends = ["Ela", "Rüzgar"] 22 | 23 | 24 | const arin = new Person("Arin", "Çekiç", 5); 25 | const elis = new Person("Elis", "Çekiç", 3); 26 | 27 | console.log(arin); 28 | console.log(elis); 29 | console.log(arin.fullName()); 30 | console.log(elis.fullName()); 31 | 32 | console.log(arin.friends); 33 | console.log(elis.friends); 34 | 35 | arin.friends.push("Çınar"); 36 | console.log(arin.friends); 37 | console.log(elis.friends); */ 38 | 39 | /* function Person(name, surname, age) { 40 | 41 | this.name = name; 42 | this.surname = surname; 43 | this.age = age; 44 | this.fullName = fullName; 45 | } */ 46 | 47 | 48 | // CLASS DECLARATION 49 | /* class Person { 50 | constructor(name, surname, age) { 51 | this.name = name; 52 | this.surname = surname; 53 | this.age = age; 54 | this.friends = ["Ela", "Rüzgar"] 55 | } 56 | 57 | fullName() { 58 | return this.name + " " + this.surname 59 | } 60 | } */ 61 | 62 | 63 | // CLASS EXPRESSION 64 | 65 | const Person = class { 66 | constructor(name, surname, age) { 67 | this.name = name; 68 | this.surname = surname; 69 | this.age = age; 70 | this.friends = ["Ela", "Rüzgar"] 71 | } 72 | 73 | fullName() { 74 | return this.name + " " + this.surname 75 | } 76 | } 77 | 78 | const arin = new Person("Arin", "Çekiç", 5); 79 | const elis = new Person("Elis", "Çekiç", 3); 80 | 81 | console.log(arin); 82 | console.log(elis); 83 | console.log(arin.fullName()); 84 | console.log(elis.fullName()); 85 | 86 | console.log(arin.friends); 87 | console.log(elis.friends); 88 | arin.friends.push("Çınar"); 89 | console.log(arin.friends); 90 | console.log(elis.friends); 91 | 92 | console.log(Person) 93 | 94 | console.log(typeof Person) 95 | -------------------------------------------------------------------------------- /ders07.js: -------------------------------------------------------------------------------- 1 | // CLASS DECLARATION 2 | /* class Person { 3 | constructor(name, surname, age) { 4 | this.name = name; 5 | this.surname = surname; 6 | this.age = age; 7 | } 8 | 9 | fullName() { 10 | return this.name + " " + this.surname; 11 | } 12 | 13 | static showName = "Person"; 14 | 15 | static staMethod() { 16 | console.log("STATIC METHOD ÇALIŞIYOR"); 17 | } 18 | } */ 19 | 20 | /* console.log(typeof Person) */ 21 | 22 | /* const arin = new Person("Arin", "Çekiç", 5); 23 | const elis = new Person("Elis", "Çekiç", 3); */ 24 | 25 | /* console.log(arin instanceof Person); 26 | console.log(elis instanceof Person); */ 27 | 28 | /* console.log(arin); 29 | console.log(elis); 30 | */ 31 | 32 | //console.log(arin.fullName()); 33 | //console.log(elis.fullName()); 34 | //console.log(Person.fullName()); 35 | 36 | //console.log(arin.showName); 37 | //console.log(arin.staMethod()); 38 | 39 | /* console.log(Person.showName); 40 | console.log(Person.staMethod()); */ 41 | 42 | /* class Person { 43 | constructor(name, surname, age) { 44 | this.name = name; 45 | this.surname = surname; 46 | this.age = age; 47 | } 48 | 49 | fullName() { 50 | return this.name + " " + this.surname; 51 | } 52 | 53 | } 54 | 55 | const arin = new Person("Arin", "Çekiç", 5) 56 | 57 | class Engineer extends Person {}; // Engineer -->Subclass (Child) Person --> Superclass (Parent) 58 | 59 | const gurcan = new Engineer("Gürcan", "Çekiç", 40); */ 60 | 61 | /* console.log(arin); 62 | console.log(gurcan); */ 63 | 64 | // OBJE + (name, surname...) => Person 65 | 66 | // Person => Engineer 67 | 68 | /* console.log(arin instanceof Person); 69 | console.log(gurcan instanceof Engineer); 70 | console.log(gurcan instanceof Person); 71 | console.log(arin instanceof Engineer); */ 72 | 73 | /* class Person { 74 | constructor(name, surname, age) { 75 | this.name = name; 76 | this.surname = surname; 77 | this.age = age; 78 | } 79 | 80 | fullName() { 81 | return this.name + " " + this.surname; 82 | } 83 | 84 | } 85 | 86 | class Engineer extends Person { 87 | constructor(name, surname, age, job) { 88 | super(name, surname, age); 89 | this.job = job; 90 | } 91 | 92 | getMoney() { 93 | console.log("PARA KAZAN"); 94 | } 95 | } 96 | 97 | const arin = new Person("Arin", "Çekiç", 5); 98 | 99 | const gurcan = new Engineer("Gürcan", "Çekiç", 40, "engineer"); 100 | 101 | console.log(arin); 102 | console.log(gurcan); 103 | 104 | // OBJE + (name, surname, age) => Person 105 | 106 | // Person + job, getMoney() => Engineer 107 | 108 | console.log(gurcan.getMoney()); 109 | //console.log(arin.getMoney()); 110 | 111 | console.log(arin instanceof Engineer); */ 112 | 113 | 114 | /* class Person { 115 | constructor(name, surname, age) { 116 | this.name = name; 117 | this.surname = surname; 118 | this.age = age; 119 | } 120 | 121 | fullName() { 122 | return this.name + " " + this.surname; 123 | } 124 | 125 | } 126 | 127 | class Engineer extends Person { 128 | constructor(name, surname, age, job) { 129 | super(name, surname, age); 130 | this.name = name; 131 | this.surname = surname; 132 | this.age = age; 133 | this.job = job; 134 | } 135 | 136 | getMoney() { 137 | console.log("PARA KAZAN"); 138 | } 139 | } 140 | 141 | const gurcan = new Engineer("Gürcan", "Çekiç", 40, "engineer"); */ 142 | 143 | class ExtendedArray extends Array { 144 | shuffle() { 145 | this.sort(() => Math.random() - 0.5); 146 | } 147 | } 148 | 149 | let myArr = new ExtendedArray(1,2,3,4,5); 150 | 151 | console.log(myArr instanceof ExtendedArray); 152 | console.log(myArr instanceof Array); 153 | console.log(myArr); 154 | myArr.shuffle(); 155 | console.log(myArr); 156 | -------------------------------------------------------------------------------- /ders08.js: -------------------------------------------------------------------------------- 1 | // obj.func() -->this obj 2 | // this --> global object --> window (global) 3 | 4 | /* console.log(this); 5 | console.log(this.location); 6 | console.log(this.location.href); 7 | console.log(window.location.href); 8 | 9 | console.log(this === window); */ 10 | 11 | 12 | /* const name = "Arin"; 13 | 14 | console.log(name); 15 | console.log(this.name); 16 | console.log(this); 17 | 18 | 19 | // Function Declaration 20 | function func1() { 21 | this.name = "Gurcan"; 22 | //console.log(this); 23 | //console.log(this.location); 24 | //console.log(this.location.href); 25 | console.log(this.age); 26 | } */ 27 | 28 | // Function Expression 29 | /* const func2 = function() { 30 | this.age = 40; 31 | //console.log(this); 32 | //console.log(this.location); 33 | //console.log(this.location.href); 34 | console.log(this.name); 35 | } */ 36 | 37 | //func1(); 38 | //func2(); 39 | 40 | /* console.log(name); 41 | console.log(age); 42 | console.log(this.name); 43 | console.log(this.age); */ 44 | 45 | //Constructor Function 46 | 47 | /* function Person(name, surname, age) { 48 | const obj = {}; 49 | console.log(obj); 50 | obj.name = name; 51 | console.log(obj); 52 | obj.surname = surname; 53 | console.log(obj); 54 | obj.age = age; 55 | obj.fullName = function() { 56 | return obj.name + " " + obj.surname 57 | } 58 | 59 | return obj; 60 | } */ 61 | 62 | 63 | /* function Person(name, surname, age) { 64 | this.name = name; 65 | this.surname = surname; 66 | this.age = age; 67 | this.fullName = function() { 68 | return this.name + " " + this.surname 69 | } 70 | } */ 71 | 72 | /* class Person { 73 | constructor (name, surname, age) { 74 | this.name = name; 75 | this.surname = surname; 76 | this.age = age; 77 | } 78 | fullName = function() { 79 | return this.name + " " + this.surname 80 | } 81 | } 82 | 83 | const arin = new Person("Arin", "Çekiç", 5); 84 | const gurcan = new Person("Gürcan", "Çekiç", 40); 85 | console.log(arin); 86 | console.log(gurcan); */ 87 | 88 | /* const arin = { 89 | name: "Arin", 90 | age: 5, 91 | surname:"Çekiç", 92 | fullName: function() { 93 | console.log(this); 94 | //return this.name + " " + this.surname 95 | }, 96 | 97 | mother : { 98 | name: "Gamze", 99 | age:40, 100 | surname:"Çekiç", 101 | fullName: function() { 102 | console.log(this); 103 | //return this.name + " " + this.surname 104 | } 105 | } 106 | 107 | } 108 | 109 | console.log(arin.fullName()); 110 | console.log(arin.mother.fullName()); */ 111 | 112 | /* const elis = { 113 | name: "Elis", 114 | funcy: function() { 115 | console.log(this === elis); 116 | console.log(this === window); 117 | } 118 | } 119 | 120 | //console.log(elis.funcy()); 121 | 122 | const funcy2 = elis.funcy; 123 | console.log(funcy2()); */ 124 | 125 | const elis = { 126 | name: "Elis", 127 | funcy: function() { 128 | console.log(this === elis); 129 | setTimeout(function() { 130 | console.log(this === elis); 131 | console.log(this === window); 132 | }, 2000); 133 | } 134 | } 135 | 136 | console.log(elis.funcy()); 137 | 138 | -------------------------------------------------------------------------------- /ders09.js: -------------------------------------------------------------------------------- 1 | /* ARROW FUNCTION */ 2 | 3 | //Function Declaration 4 | 5 | /* console.log(square(4)); 6 | 7 | function square(num) { 8 | return (num*num); 9 | } 10 | 11 | 12 | // Function Expression 13 | 14 | const square2 = function(num) { 15 | return (num*num) 16 | } 17 | 18 | console.log(square2(6)); 19 | 20 | // Arrow Function Expression 21 | 22 | //const square3 = function(num) { return (num*num) }; 23 | //const square3 = (num) => { return (num*num) }; 24 | const square3 = num => (num*num); 25 | 26 | console.log(square3(8)); 27 | 28 | */ 29 | 30 | /* window.name = 'arin'; 31 | 32 | function tellName() { 33 | console.log(this); 34 | console.log(this.name); 35 | } 36 | 37 | tellName(); 38 | 39 | const person = { 40 | name: 'elis', 41 | tellName: function() { 42 | console.log(this); 43 | console.log(this.name) 44 | } 45 | } 46 | 47 | person.tellName(); */ 48 | 49 | /* window.name = 'arin'; 50 | 51 | const tellName = () => { 52 | console.log(this); 53 | console.log(this.name); 54 | } 55 | 56 | tellName(); 57 | 58 | const person = { 59 | name: 'elis', 60 | tellName: () => { 61 | console.log(this); 62 | console.log(this.name) 63 | } 64 | } 65 | 66 | person.tellName(); */ 67 | 68 | /* window.name = 'arin'; 69 | 70 | const person = { 71 | name: 'elis', 72 | tellName:function() { 73 | console.log(this); 74 | console.log(this.name); 75 | 76 | setTimeout(function() { 77 | console.log(this); 78 | console.log(this.name); 79 | }, 2000) 80 | } 81 | } 82 | 83 | person.tellName(); */ 84 | 85 | /* window.name = 'arin'; 86 | 87 | const person = { 88 | name: 'elis', 89 | tellName:function() { 90 | console.log(this); 91 | console.log(this.name); 92 | 93 | setTimeout(()=> { 94 | console.log(this); 95 | console.log(this.name); 96 | }, 2000) 97 | } 98 | } 99 | 100 | person.tellName(); */ 101 | 102 | /* const Person = (name, surname, age) => { 103 | 104 | this.name = name; 105 | this.surname = surname; 106 | this.age = age; 107 | this.fullName = function() { 108 | return this.name + " " + this.surname 109 | } 110 | } 111 | 112 | const person1 = new Person("John", "Doe", 40); 113 | 114 | console.log(person1) */ 115 | 116 | /* window.year = 100; 117 | 118 | const myObj = { 119 | year: 2020, 120 | showYear1: function() { 121 | console.log(this.year, this) 122 | }, 123 | showYear2: () => console.log(this.year, this) 124 | } 125 | 126 | myObj.showYear1(); 127 | myObj.showYear2(); */ 128 | 129 | // CALL 130 | 131 | window.name = 'gurcan'; 132 | window.grade = 100; 133 | 134 | const student = { 135 | examResult: () => { 136 | return this.name + " " + this.grade 137 | } 138 | } 139 | 140 | const student1 = { 141 | name: 'arin', 142 | grade: 80 143 | } 144 | 145 | const student2 = { 146 | name: 'elis', 147 | grade: 77 148 | } 149 | 150 | console.log(student.examResult.call(student1)); 151 | console.log(student.examResult.call(student2)); 152 | 153 | -------------------------------------------------------------------------------- /ders10.js: -------------------------------------------------------------------------------- 1 | // JS Single Thread 2 | // JS Synchronous 3 | 4 | /* const func1 = () => { 5 | console.log("Func 1 Console Log 1"); 6 | 7 | console.log("Func 1 Console Log 2"); 8 | 9 | alert('Alert Message'); 10 | } 11 | 12 | const func2 = () => { 13 | console.log("Func 2 Console Log 1"); 14 | 15 | console.log("Func 2 Console Log 2"); 16 | } 17 | 18 | func1(); 19 | func2(); */ 20 | 21 | /* let x = 10; 22 | console.log("1. Gelen Veri", x); 23 | 24 | 25 | setTimeout(() => { 26 | x = x + 5; 27 | }, 1000) 28 | 29 | console.log("2. Gelen Veri", x); 30 | 31 | 32 | 33 | x = x + 5; 34 | console.log("3. Gelen Veri", x); */ 35 | 36 | // Call Stack 37 | 38 | /* function func1() { 39 | console.log("Ben birinciyim"); 40 | func2(); 41 | console.log("Ben tekrar birinciyim"); 42 | } 43 | 44 | function func2() { 45 | console.log("Ben ikinciyim"); 46 | func3(); 47 | console.log("Ben tekrar ikinciyim"); 48 | } 49 | 50 | function func3() { 51 | console.log("Ben üçüncüyüm"); 52 | } 53 | 54 | func1(); */ 55 | 56 | /* function add(x, y) { 57 | return x + y; 58 | } 59 | 60 | function average(x,y) { 61 | return add(x, y) / 2 62 | } 63 | 64 | let x = average(6, 8); */ 65 | 66 | /* function task(message) { 67 | let n = 10000000000; 68 | while(n > 0) { 69 | n-- 70 | } 71 | 72 | console.log(message); 73 | } 74 | 75 | console.log('1'); 76 | 77 | setTimeout(()=> { 78 | console.log('2'); 79 | }, 1000) 80 | 81 | console.log('3'); 82 | console.log('4'); 83 | 84 | task('İşlem Tamamlandı'); 85 | 86 | setTimeout(()=> { 87 | console.log('5'); 88 | }, 2000) 89 | 90 | task('İşlem Tamamlandı 2'); 91 | */ 92 | 93 | /* const myName = () => { 94 | console.log("Benim adım Arin"); 95 | } 96 | 97 | setTimeout(myName, 3000); */ 98 | 99 | /* setTimeout(() => { 100 | console.log("Benim adım Arin"); 101 | }, 3000); */ 102 | 103 | const books = [ 104 | {name: "Pinball 1973", author: "Haruki Murakami"}, 105 | {name: "Özgürlük", author: "Zygmunt Bauman"}, 106 | {name: "Turkiye'de Çağdaşlaşma", author:"Niyazi Berkes"} 107 | ] 108 | 109 | const listBooks = () => { 110 | books.map((book, index) => { 111 | console.log(book, index) 112 | }) 113 | } 114 | 115 | 116 | 117 | const addNewBook = (newBook, callback) => { 118 | books.push(newBook) 119 | callback(); 120 | } 121 | 122 | addNewBook({name: "Berlin Hatıralım", author: "Hüsrev Gerede"}, listBooks); 123 | 124 | -------------------------------------------------------------------------------- /ders11.js: -------------------------------------------------------------------------------- 1 | // PROMISE 2 | 3 | /* const books = [ 4 | {name: "Pinball 1973", author: "Haruki Murakami"}, 5 | {name: "Özgürlük", author: "Zygmunt Bauman"}, 6 | {name: "Turkiye'de Çağdaşlaşma", author:"Niyazi Berkes"} 7 | ] 8 | 9 | const listBooks = () => { 10 | books.map((book, index) => { 11 | console.log(book, index) 12 | }) 13 | } */ 14 | 15 | /* const addNewBook = (newBook) => { 16 | books.push(newBook) 17 | } 18 | */ 19 | 20 | /* addNewBook({name: "Berlin Hatıralım", author: "Hüsrev Gerede"}); 21 | 22 | listBooks(); */ 23 | 24 | /* const addNewBook = (newBook, callback) => { 25 | books.push(newBook) 26 | callback(); 27 | } 28 | 29 | addNewBook({name: "Berlin Hatıralım", author: "Hüsrev Gerede"}, listBooks); */ 30 | 31 | /* const promise1 = new Promise(function(resolve, reject) { 32 | reject('ERROR2'); 33 | resolve('DATA'); 34 | resolve('DATA2'); 35 | reject('ERROR'); 36 | reject('ERROR2'); 37 | }) 38 | 39 | console.log(promise1); */ 40 | 41 | // pending (undefined) - fullfilled - rejected => PROMISE STATE 42 | 43 | /* const promise1 = new Promise(function(resolve, reject) { 44 | //resolve('DATA'); 45 | reject('ERROR'); 46 | }) */ 47 | 48 | //console.log(promise1.value); 49 | 50 | /* promise1.then(function (value) { 51 | console.log(value) 52 | }) */ 53 | 54 | /* promise1.then((value) => { 55 | console.log(value) 56 | }) */ 57 | 58 | //promise1.then(value => console.log(value)); 59 | //promise1.catch(reason => console.log(reason)); 60 | 61 | /* const promise1 = new Promise((resolve, reject) => { 62 | 63 | //resolve(); 64 | 65 | reject(); 66 | 67 | }) */ 68 | 69 | /* promise1.then(()=> { 70 | console.log('VERILER ALINDI'); 71 | }); */ 72 | 73 | /* promise1.catch(()=> { 74 | console.log('VERILER ALINMADI'); 75 | }); */ 76 | 77 | /* promise1 78 | .then(()=> { 79 | console.log('VERILER ALINDI'); 80 | }) 81 | .catch(()=> { 82 | console.log('VERILER ALINMADI'); 83 | }) 84 | .finally(()=> { 85 | console.log('ÇALIŞ KÖLE') 86 | }) */ 87 | 88 | /* const promise1 = new Promise((resolve, reject) => { 89 | 90 | //resolve(); 91 | 92 | reject(); 93 | 94 | }) 95 | 96 | promise1.then(()=> { 97 | console.log('VERILER ALINDI'); 98 | },()=> { 99 | console.log('VERILER ALINMADIIIIII'); 100 | } 101 | 102 | ) */ 103 | 104 | const books = [ 105 | {name: "Pinball 1973", author: "Haruki Murakami"}, 106 | {name: "Özgürlük", author: "Zygmunt Bauman"}, 107 | {name: "Turkiye'de Çağdaşlaşma", author:"Niyazi Berkes"} 108 | ] 109 | 110 | const listBooks = () => { 111 | books.map((book, index) => { 112 | console.log(book, index) 113 | }) 114 | } 115 | 116 | 117 | /* const addNewBook = (newBook, callback) => { 118 | books.push(newBook) 119 | callback(); 120 | } */ 121 | 122 | /* const addNewBook = (newBook) => { 123 | const promise1 = new Promise((resolve, reject) => { 124 | books.push(newBook) 125 | //resolve(books) 126 | reject() 127 | }) 128 | 129 | return promise1 130 | } */ 131 | 132 | //addNewBook({name: "Berlin Hatıralım", author: "Hüsrev Gerede"}, listBooks); 133 | 134 | /* addNewBook({name: "Berlin Hatıralım", author: "Hüsrev Gerede"}) 135 | .then(()=> { 136 | console.log('Yeni List'); 137 | listBooks(); 138 | }).catch(()=> { 139 | console.log('HATA ALDIK 2') 140 | }) */ 141 | 142 | const addTwoNumbers = (num1, num2) => { 143 | const promise2 = new Promise((resolve, reject) => { 144 | const sum = num1 + num2; 145 | (typeof num1 !== 'number' || typeof num2 !== 'number') 146 | ? reject('2 SAYI GİRMENİZ GEREKİR') 147 | : resolve(sum) 148 | }) 149 | return promise2 150 | } 151 | 152 | addTwoNumbers(4,'8') 153 | .then((value) => { 154 | console.log('TOPLAM: ', value) 155 | }) 156 | .catch((reason) => { 157 | console.log('HATA: ', reason) 158 | }) -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 |