{"id":3594,"date":"2020-06-08T19:03:33","date_gmt":"2020-06-08T16:03:33","guid":{"rendered":"https:\/\/elzero.org\/?p=3594"},"modified":"2020-06-12T22:39:46","modified_gmt":"2020-06-12T19:39:46","slug":"define-object-with-object-assign","status":"publish","type":"post","link":"https:\/\/elzero.org\/old\/define-object-with-object-assign\/","title":{"rendered":"Define Object With Object.assign"},"content":{"rendered":"<h3>\u0627\u0644 Code \u0627\u0644\u0645\u0648\u062c\u0648\u062f \u0641\u064a \u0627\u0644\u062f\u0631\u0633<\/h3>\r\n<script type=\"text\/plain\" class=\"language-javascript\">\r\n\/*\r\n  Defining Object\r\n  [1] Object Literal\r\n  [2] With New Keyword\r\n  [3] With Object.create()\r\n  [4] With Object.assign()\r\n*\/\r\n\r\nconst src1 = {\r\n  prop1: \"Value1\",\r\n  prop2: \"Value2\",\r\n  method1: function () {\r\n    return `Method 1`;\r\n  },\r\n};\r\n\r\nconst src2 = {\r\n  prop3: \"Value3\",\r\n  prop4: \"Value4\",\r\n  method2: function () {\r\n    return `Method 2`;\r\n  },\r\n};\r\n\r\nconst target = {\r\n  prop5: \"Value5\",\r\n};\r\n\r\nObject.assign(target, src1, src2, { prop6: \"Value6\" });\r\n\r\nconsole.log(target);\r\n\r\nconst myObject = Object.assign({}, target, { prop7: \"Value7\" });\r\n\r\nconsole.log(myObject);\r\nconsole.log(myObject.prop1);\r\nconsole.log(myObject.prop2);\r\nconsole.log(myObject.prop6);\r\nconsole.log(myObject.method1());\r\nconsole.log(myObject.method2());\r\n\r\n<\/script>\r\n<hr>\r\n<h3>\u0645\u0644\u0627\u062d\u0638\u0627\u062a \u0627\u0644\u062f\u0631\u0633<\/h3>\r\n\u0644\u0627 \u062a\u0648\u062c\u062f \u0645\u0644\u0627\u062d\u0638\u0627\u062a \u062d\u0627\u0644\u064a\u0627","protected":false},"excerpt":{"rendered":"<p>\u0627\u0644 Code \u0627\u0644\u0645\u0648\u062c\u0648\u062f \u0641\u064a \u0627\u0644\u062f\u0631\u0633 \u0645\u0644\u0627\u062d\u0638\u0627\u062a \u0627\u0644\u062f\u0631\u0633 \u0644\u0627 \u062a\u0648\u062c\u062f \u0645\u0644\u0627\u062d\u0638\u0627\u062a \u062d\u0627\u0644\u064a\u0627<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[436],"tags":[],"class_list":["post-3594","post","type-post","status-publish","format-standard","hentry","category-javascript-oop"],"_links":{"self":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/3594","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/comments?post=3594"}],"version-history":[{"count":2,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/3594\/revisions"}],"predecessor-version":[{"id":3768,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/3594\/revisions\/3768"}],"wp:attachment":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/media?parent=3594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/categories?post=3594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/tags?post=3594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}