Typescript -> TypeScript (english) (#35206)
This commit is contained in:
@@ -4,7 +4,7 @@ title: Any Type
|
||||
|
||||
# Any Type
|
||||
|
||||
The Any type instructs Typescript to suspend type checking for the specified variables. Useful when working with dynamic content for which you don't know the type, and for transitioning your codebase from JavaScript to Typescript in pieces. You can use JavaScript's implicit typing with variables declared with a type of Any.
|
||||
The Any type instructs TypeScript to suspend type checking for the specified variables. Useful when working with dynamic content for which you don't know the type, and for transitioning your codebase from JavaScript to TypeScript in pieces. You can use JavaScript's implicit typing with variables declared with a type of Any.
|
||||
|
||||
Although the Any type can be helpful in specific circumstances, it should be used with caution, since it means we opt out of TypeScript's typechecking.
|
||||
|
||||
|
@@ -20,7 +20,7 @@ let names: Array<string> = ['Javier', 'Emma', 'John', 'Sophia', 'Emma'];
|
||||
```
|
||||
|
||||
## Built-in methods
|
||||
In Typescript's Array type you can use some built-in functions. Each type has common and unique methods.
|
||||
In TypeScript's Array type you can use some built-in functions. Each type has common and unique methods.
|
||||
Below you can read about the most used methods of the Array type. In the example, we will use the array declaration from above.
|
||||
|
||||
### pop()
|
||||
|
@@ -1,27 +1,27 @@
|
||||
---
|
||||
title: Getters & Setters
|
||||
---
|
||||
|
||||
# Getters & Setters
|
||||
|
||||
Typescript also supports `get` and `set` property. Get and Set Properties are actually called Accessors. Accessors of a property contains executable statements associated with getting (reading) or setting (writing) the property. The declarations can contain get accessor or set accessor or both.
|
||||
|
||||
```typescript
|
||||
class User {
|
||||
private _fullName: string = '';
|
||||
|
||||
get fullName() {
|
||||
return this._fullName;
|
||||
}
|
||||
|
||||
set fullName(name) {
|
||||
this._fullName = name;
|
||||
}
|
||||
}
|
||||
|
||||
let user = new User();
|
||||
|
||||
user.fullName = 'John Doe';
|
||||
|
||||
console.log(user.fullName);
|
||||
```
|
||||
---
|
||||
title: Getters & Setters
|
||||
---
|
||||
|
||||
# Getters & Setters
|
||||
|
||||
TypeScript also supports `get` and `set` property. Get and Set Properties are actually called Accessors. Accessors of a property contains executable statements associated with getting (reading) or setting (writing) the property. The declarations can contain get accessor or set accessor or both.
|
||||
|
||||
```typescript
|
||||
class User {
|
||||
private _fullName: string = '';
|
||||
|
||||
get fullName() {
|
||||
return this._fullName;
|
||||
}
|
||||
|
||||
set fullName(name) {
|
||||
this._fullName = name;
|
||||
}
|
||||
}
|
||||
|
||||
let user = new User();
|
||||
|
||||
user.fullName = 'John Doe';
|
||||
|
||||
console.log(user.fullName);
|
||||
```
|
||||
|
@@ -18,7 +18,7 @@ let greeting: string = `Hello, ${firstName} ${lastName}, thank you for attending
|
||||
```
|
||||
|
||||
## Built-in methods
|
||||
In Typescript you can use some built-in functions for specific types. Each type has common and unique methods.
|
||||
In TypeScript you can use some built-in functions for specific types. Each type has common and unique methods.
|
||||
Below you can read about the most used common methods for the string type.
|
||||
|
||||
### split('separator', limit)
|
||||
|
Reference in New Issue
Block a user