{"id":287510,"date":"2018-08-16T14:10:49","date_gmt":"2018-08-16T10:10:49","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=287510"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=287510","title":{"rendered":"\u0410\u043d\u0430\u043b\u043e\u0433\u0438 \u0432 Python \u0438 JavaScript. \u0427\u0430\u0441\u0442\u044c \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0430\u044f"},"content":{"rendered":"\n<div data-io-article-url=\"https:\/\/habr.com\/post\/419271\/\" class=\"post__text post__text-html js-mediator-article\">\n<p>\u0427\u0435\u0442\u0432\u0435\u0440\u0442\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u0440\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438 \u0432 Python \u0438 JavaScript.<\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438: \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438, \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435, \u0433\u0435\u0442\u0442\u0435\u0440\u044b-\u0441\u0435\u0442\u0442\u0435\u0440\u044b \u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>  <\/p>\n<p>\u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0447\u0430\u0441\u0442\u0435\u0439:<\/p>\n<p>  <\/p>\n<ol>\n<li><a href=\"https:\/\/habr.com\/post\/416617\/\">\u0427\u0430\u0441\u0442\u044c \u043f\u0435\u0440\u0432\u0430\u044f<\/a>: \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a \u0442\u0438\u043f\u0443, \u0442\u0435\u0440\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440, \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0441\u043b\u043e\u0432\u0430\u0440\u0438, \u0441\u043f\u0438\u0441\u043a\u0438, \u0441\u0442\u0440\u043e\u043a\u0438, \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u044f \u0441\u0442\u0440\u043e\u043a.<\/li>\n<li><a href=\"https:\/\/habr.com\/post\/417513\/\">\u0427\u0430\u0441\u0442\u044c \u0432\u0442\u043e\u0440\u0430\u044f<\/a>: JSON, \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u0438, \u043e\u0448\u0438\u0431\u043a\u0438-\u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/li>\n<li><a href=\"https:\/\/habr.com\/post\/418191\/\">\u0427\u0430\u0441\u0442\u044c \u0442\u0440\u0435\u0442\u044c\u044f<\/a>: \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 Python \u0438 JS: \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b (f-\u0441\u0442\u0440\u043e\u043a\u0438), \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0430 \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u043b\u044f\u043c\u0431\u0434\u0430-\u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0430\u043c, \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b, \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430.<a name=\"habracut\"><\/a><\/li>\n<\/ol>\n<p>  <\/p>\n<h4 id=\"argumenty-funkciy\">\u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/h4>\n<p>  <\/p>\n<p>\u0423 \u041f\u0438\u0442\u043e\u043d\u0430 \u043e\u0431\u0448\u0438\u0440\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u2014 \u0435\u0441\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0438 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 (<code>*args<\/code> \u0438 <code>**kwargs<\/code>). <\/p>\n<p>  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0438\u043c\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043e. \u0412 JS \u0442\u043e\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u043a\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0432 \u041f\u0438\u0442\u043e\u043d\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from pprint import pprint  def report(post_id, reason='not-relevant'):     pprint({'post_id': post_id, 'reason': reason})  report(42) report(post_id=24, reason='spam')<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 JS \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function report(post_id, reason='not-relevant') {     console.log({post_id: post_id, reason: reason}); }  report(42); report(post_id=24, reason='spam');<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432 \u041f\u0438\u0442\u043e\u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>*<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from pprint import pprint  def add_tags(post_id, *tags):     pprint({'post_id': post_id, 'tags': tags})  add_tags(42, 'python', 'javascript', 'django')<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 JS \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <code>...<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function add_tags(post_id, ...tags) {     console.log({post_id: post_id, tags: tags}); }  add_tags(42, 'python', 'javascript', 'django');    <\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u041f\u0438\u0442\u043e\u043d\u0435 \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from pprint import pprint  def create_post(**options):     pprint(options)  create_post(     title='Hello, World!',      content='This is our first post.',     is_published=True, ) create_post(     title='Hello again!',     content='This is our second post.', )<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 JS \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u043e\u0432\u0430\u0440\u044f (<code>options<\/code> \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435):<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function create_post(options) {     console.log(options); }  create_post({     'title': 'Hello, World!',      'content': 'This is our first post.',     'is_published': true }); create_post({     'title': 'Hello again!',      'content': 'This is our second post.' });<\/code><\/pre>\n<p>  <\/p>\n<h4 id=\"klassy-i-nasledovanie\">\u041a\u043b\u0430\u0441\u0441\u044b \u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435<\/h4>\n<p>  <\/p>\n<p>\u041f\u0438\u0442\u043e\u043d \u2014 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u044f\u0437\u044b\u043a. JS \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 ECMAScript 6 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0431\u0435\u0437 \u0432\u0441\u044f\u043a\u0438\u0445 \u0443\u043b\u043e\u0432\u043e\u043a \u0438 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u0431\u043e\u0440\u043e\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u041f\u0438\u0442\u043e\u043d. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0438 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class Post(object):     def __init__(self, id, title):         self.id = id         self.title = title      def __str__(self):         return self.title  post = Post(42, 'Hello, World!') isinstance(post, Post) == True print(post)  # Hello, World!<\/code><\/pre>\n<p>  <\/p>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0430 JS:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class Post {     constructor (id, title) {         this.id = id;         this.title = title;     }     toString() {         return this.title;     } }  post = new Post(42, 'Hello, World!'); post instanceof Post === true; console.log(post.toString());  \/\/ Hello, World!<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Article<\/code> \u0438 <code>Link<\/code> \u0432 \u041f\u0438\u0442\u043e\u043d\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Post<\/code>. \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e<code>super<\/code> \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043c\u0435\u0442\u043e\u0434\u0430\u043c \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 <code>Post<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class Article(Post):     def __init__(self, id, title, content):         super(Article, self).__init__(id, title)         self.content = content  class Link(Post):     def __init__(self, id, title, url):         super(Link, self).__init__(id, title)         self.url = url      def __str__(self):         return '{} ({})'.format(             super(Link, self).__str__(),             self.url,         )  article = Article(1, 'Hello, World!', 'This is my first article.') link = Link(2, 'DjangoTricks', 'https:\/\/djangotricks.blogspot.com') isinstance(article, Post) == True isinstance(link, Post) == True print(link) # DjangoTricks (https:\/\/djangotricks.blogspot.com)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0432 JS:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class Article extends Post {     constructor (id, title, content) {         super(id, title);         this.content = content;     } }  class Link extends Post {     constructor (id, title, url) {         super(id, title);         this.url = url;     }     toString() {         return super.toString() + ' (' + this.url + ')';     } }  article = new Article(1, 'Hello, World!', 'This is my first article.'); link = new Link(2, 'DjangoTricks', 'https:\/\/djangotricks.blogspot.com'); article instanceof Post === true; link instanceof Post === true; console.log(link.toString()); \/\/ DjangoTricks (https:\/\/djangotricks.blogspot.com)<\/code><\/pre>\n<p>  <\/p>\n<h4 id=\"svoystva-klassa-gettery-i-settery\">\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430: \u0433\u0435\u0442\u0442\u0435\u0440\u044b \u0438 \u0441\u0435\u0442\u0442\u0435\u0440\u044b.<\/h4>\n<p>  <\/p>\n<p>\u0412 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0443 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0435\u0441\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b, \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430. \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u2014 \u044d\u0442\u043e \u0441\u043c\u0435\u0441\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0441\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 \u043a\u0430\u043a \u0441 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438, \u043d\u043e \u0433\u0434\u0435-\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u043d\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0433\u0435\u0442\u0442\u0435\u0440\u0430\u043c\u0438 \u0438 \u0441\u0435\u0442\u0442\u0435\u0440\u0430\u043c\u0438 (getters\/setters) \u0434\u043b\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<br \/>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0430 \u041f\u0438\u0442\u043e\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0433\u0435\u0442\u0442\u0435\u0440\u0430 \u0438 \u0441\u0435\u0442\u0442\u0435\u0440\u0430 \u0434\u043b\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>slug<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class Post(object):     def __init__(self, id, title):         self.id = id         self.title = title         self._slug = ''      @property     def slug(self):         return self._slug      @slug.setter     def slug(self, value):         self._slug = value  post = Post(1, 'Hello, World!') post.slug = 'hello-world' print(post.slug)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 JS \u0433\u0435\u0442\u0442\u0435\u0440 \u0438 \u0441\u0435\u0442\u0442\u0435\u0440 \u0434\u043b\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>slug<\/code> \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043a\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class Post {     constructor (id, title) {         this.id = id;         this.title = title;         this._slug = '';     }      set slug(value) {         this._slug = value;     }      get slug() {         return this._slug;     } }  post = new Post(1, 'Hello, World!'); post.slug = 'hello-world'; console.log(post.slug);<\/code><\/pre>\n<p>  <\/p>\n<h4 id=\"vyvody\">\u0412\u044b\u0432\u043e\u0434\u044b<\/h4>\n<p>  <\/p>\n<ul>\n<li>\u0412 \u043e\u0431\u043e\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/li>\n<li>\u0412 \u043e\u0431\u043e\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432.<\/li>\n<li>\u041e\u0431\u0430 \u044f\u0437\u044b\u043a\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041d\u0443, \u0438 \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u0430\u0432\u0442\u043e\u0440 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430 <a href=\"https:\/\/gumroad.com\/l\/python-vs-javascript\">\u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043a\u0443\u043f\u0438\u0442\u044c \u0443 \u043d\u0435\u0433\u043e \u043f\u0434\u0444\u043a\u0443 \u0441 \u0446\u0432\u0435\u0442\u043d\u044b\u043c\u0438 \u0448\u043f\u0430\u0440\u0433\u0430\u043b\u043a\u0430\u043c\u0438 \u043f\u043e \u043f\u0438\u0442\u043e\u043d\u0443 \u0438 \u0434\u0436\u0430\u0432\u0430\u0441\u043a\u0440\u0438\u043f\u0442\u0443 \u0437\u0430 \u043f\u044f\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u044c \u0431\u0430\u043a\u0441\u043e\u0432<\/a>. <\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0438 \u043f\u043e\u0432\u0435\u0441\u0438\u0442\u044c \u043d\u0430 \u0441\u0442\u0435\u043d\u0443 \u0438\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u0443\u043c\u0430\u0436\u043d\u044b\u0439 \u0441\u0430\u043c\u043e\u043b\u0435\u0442\u0438\u043a \u2014 \u0440\u0435\u0448\u0430\u0442\u044c \u0432\u0430\u043c!<\/p>\n<\/div>\n<p>        <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/post\/419271\/\"> https:\/\/habr.com\/post\/419271\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div data-io-article-url=\"https:\/\/habr.com\/post\/419271\/\" class=\"post__text post__text-html js-mediator-article\">\n<p>\u0427\u0435\u0442\u0432\u0435\u0440\u0442\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u0440\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438 \u0432 Python \u0438 JavaScript.<\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438: \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438, \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435, \u0433\u0435\u0442\u0442\u0435\u0440\u044b-\u0441\u0435\u0442\u0442\u0435\u0440\u044b \u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>  <\/p>\n<p>\u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0447\u0430\u0441\u0442\u0435\u0439:<\/p>\n<p>  <\/p>\n<ol>\n<li><a href=\"https:\/\/habr.com\/post\/416617\/\">\u0427\u0430\u0441\u0442\u044c \u043f\u0435\u0440\u0432\u0430\u044f<\/a>: \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a \u0442\u0438\u043f\u0443, \u0442\u0435\u0440\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440, \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0441\u043b\u043e\u0432\u0430\u0440\u0438, \u0441\u043f\u0438\u0441\u043a\u0438, \u0441\u0442\u0440\u043e\u043a\u0438, \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u044f \u0441\u0442\u0440\u043e\u043a.<\/li>\n<li><a href=\"https:\/\/habr.com\/post\/417513\/\">\u0427\u0430\u0441\u0442\u044c \u0432\u0442\u043e\u0440\u0430\u044f<\/a>: JSON, \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u0438, \u043e\u0448\u0438\u0431\u043a\u0438-\u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/li>\n<li><a href=\"https:\/\/habr.com\/post\/418191\/\">\u0427\u0430\u0441\u0442\u044c \u0442\u0440\u0435\u0442\u044c\u044f<\/a>: \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 Python \u0438 JS: \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b (f-\u0441\u0442\u0440\u043e\u043a\u0438), \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0430 \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u043b\u044f\u043c\u0431\u0434\u0430-\u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0430\u043c, \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b, \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430.<br \/>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-287510","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/287510","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=287510"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/287510\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=287510"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=287510"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=287510"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}