TypeScript या ES6: Angular में शुरुआत करने वाले के लिए क्या चुनें?
सभी को नमस्ते! मैं एक शुरुआती फ्रंटएंड डेवलपर हूँ और Angular सीख रहा हूँ। मैं देख रहा हूँ कि Angular के सभी प्रोजेक्ट TypeScript में लिखे जाते हैं, लेकिन मुझे ES6 (ES2015) अच्छी तरह से आता है। मुझे लगता है कि ES6 पहले से ही arrow functions, classes, modules, promises देता है — आधुनिक डेवलपमेंट के लिए ये सब ज़रूरी लगता है।
उदाहरण के लिए, ES6 में एक सरल component:
```javascript
class UserComponent {
constructor(userService) {
this.userService = userService;
}
getUser(id) {
return this.userService.fetch(id).then(user => {
this.user = user;
this.render();
});
}
render() {
console.log(`User: ${this.user.name}`);
}
}
```
वही कोड TypeScript में ज़्यादा बड़ा दिखता है:
```typescript
class UserComponent {
private user: any;
```