Created
November 22, 2017 06:21
-
-
Save serrrgggeee/1ee44f461e429f9fd04f0c210c1b5fa7 to your computer and use it in GitHub Desktop.
This file contains 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
// в этом примере при изменении dumbMethod он будет менятья во всех instance | |
function DumbConstructor() { } | |
DumbConstructor.prototype.dumbMethod = function() { return } | |
// в этом примере при изменении dumbMethod он будет менятья только в instance в которой он меняется | |
function DumbConstructor() { | |
this.dumbMethod = function() { return } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Оба примера полезные в разных случаях, если я например хочу чтобы в системе у меня была какаято одинаковая величина или метод для всех объектов то это первый пример, а если только в одном объекте чтото поменять, то это второй