1#  ``Function.bind`` is not supported
2
3Rule ``arkts-no-func-bind``
4
5**Severity: warning**
6
7ArkTS does not allow using standard library function ``Function.bind``.
8This API is needed in the standard library to explicitly set ``this``
9parameter for the called function.
10In ArkTS the semantics of ``this`` is restricted to the conventional OOP
11style, and the usage of ``this`` in stand-alone functions is prohibited.
12Thus this function is excessive.
13
14
15## TypeScript
16
17
18```
19
20    const person = {
21        firstName: "aa",
22
23        fullName: function(): string {
24            return this.firstName
25        }
26    }
27
28    const person1 = {
29        firstName: "Mary"
30    }
31
32    // This will log "Mary":
33    const boundFullName = person.fullName.bind(person1)
34    console.log(boundFullName())
35
36```
37
38## ArkTS
39
40
41```
42
43    class Person {
44        firstName : string
45
46        constructor(firstName : string) {
47            this.firstName = firstName
48        }
49        fullName() : string {
50            return this.firstName
51        }
52    }
53
54    let person = new Person("")
55    let person1 = new Person("Mary")
56
57    // This will log "Mary":
58    console.log(person1.fullName())
59
60```
61
62## See also
63
64- Recipe 093:  Using ``this`` inside stand-alone functions is not supported (``arkts-no-standalone-this``)
65
66
67