Advertisement
Guest User

Untitled

a guest
Jul 24th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. "use strict";
  2. // Использование функции вопросов
  3.  
  4. function ask(question, answer, ok, fail) {
  5. var result = prompt(question, '');
  6. if (result.toLowerCase() == answer.toLowerCase()) ok();
  7. else fail();
  8. }
  9.  
  10. var user = {
  11. login: 'Василий',
  12. password: '12345',
  13.  
  14. loginOk: function() {
  15. alert( this.login + ' вошёл в сайт' );
  16. },
  17.  
  18. loginFail: function() {
  19. alert( this.login + ': ошибка входа' );
  20. },
  21.  
  22. checkPassword: function() {
  23. ask("Ваш пароль?", this.password, this.loginOk.bind( this ), this.loginFail.bind( this ));
  24. }
  25. };
  26.  
  27. var vasya = user;
  28. user = null;
  29. vasya.checkPassword();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement