Показать сообщение отдельно
  #14 (permalink)  
Старый 26.08.2015, 13:41
Профессор
Отправить личное сообщение для tsigel Посмотреть профиль Найти все сообщения от tsigel
 
Регистрация: 12.12.2012
Сообщений: 1,398

HJ90,
var $ = function (some) {
   if (!(this instanceof $)) {
      return new $(some);
   }
   console.log(some);
};
$.prototype.method1 = function () {
   console.log(1);
   return this;
};

$.prototype.method2 = function () {
   console.log(2);
   return this;
};

$.prototype.method3 = function () {
   console.log(3);
   return this;
};

$('test').method1().method2().method3().method1().method2().method3();//...
$('test').method1();
var t = $('test');
t.method2();
Ответить с цитированием