This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class User { | |
| constructor(name, email) { | |
| this.name = name; | |
| this.email = email; | |
| } | |
| } | |
| let handler = { | |
| deleteProperty(target, prop) { | |
| if (prop === "email") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Book { | |
| constructor(title, author, available) { | |
| this.title = title; | |
| this.author = author; | |
| this.available = available; | |
| } | |
| } | |
| let handler = { | |
| has(target, prop) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class User { | |
| constructor(email) { | |
| this.email = email; | |
| } | |
| } | |
| let handler = { | |
| construct(target, args) { | |
| let email = args[0]; | |
| if (!isValidEmail(email)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let user = { | |
| name: "John", | |
| age: 30 | |
| }; | |
| let handler = { | |
| get: function(target, prop, receiver) { | |
| if (prop === "name") { | |
| return target[prop]; | |
| } else if (prop === "age") { | |
| throw new Error("Yaş özelliğine erişmek için izin verilmiyor!"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Person = { | |
| name: string; | |
| age: number; | |
| }; | |
| type Address = { | |
| street: string; | |
| city: string; | |
| postalCode: number; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum Direction { | |
| Up = "UP", | |
| Down = "DOWN", | |
| Left = "LEFT", | |
| Right = "RIGHT", | |
| } | |
| const up = Direction.Up; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // String literal type | |
| const name: "John Doe" = "John Doe"; | |
| // Number literal type | |
| const age: 30 = 30; | |
| // Boolean literal type | |
| const isLoggedIn: true = true; | |
| // Enum literal type |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const element = document.getElementById("my-element"); | |
| // element'in HTMLElement türünde olduğunu varsayıyoruz | |
| const button = <HTMLButtonElement>element; | |
| button.addEventListener("click", () => { | |
| // ... | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const element = document.getElementById("my-element"); | |
| // element'in HTMLElement türünde olduğunu varsayıyoruz | |
| const button = element as HTMLButtonElement; | |
| button.addEventListener("click", () => { | |
| // ... | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Window = { | |
| title: string; | |
| } | |
| type Window = { | |
| ts: TypeScriptAPI; | |
| } | |
| // Error: Duplicate identifier 'Window'. |
NewerOlder