Browse Source

this fixes

Ivan Asmer 8 years ago
parent
commit
6c35627de7
1 changed files with 9 additions and 1 deletions
  1. 9 1
      07ObjectsFunctionalStyle.md

+ 9 - 1
07ObjectsFunctionalStyle.md

@@ -35,7 +35,7 @@ function Person(name, surname){
     this.name    = name
     this.surname = surname
 
-    this.getFullName = function(){
+    this.getFullName = function(/*this*/){
         return this.name + (this.fatherName ? " " + this.fatherName + " " : " ") + this.surname
     }
 }
@@ -47,6 +47,14 @@ person.fatherName = "Sydorych"
 alert(person.getFullName())
 ```
 
+`this` можно считать скрытым параметром функции, если функция **вызвана через точку** как поле объекта:
+
+```javascript
+alert(person.getFullName()) //в качестве this в getFullName передается person
+```
+
+
+
 ## Приватные методы и данные; Замыкания.
 
 **JS** не предоставляет обычных для Объектно-ориентированных языков программирования возможностей ограничения доступа к полям объекта (`private`, `public`, `protected`), для этого используется