{"id":4344,"date":"2020-06-26T02:23:30","date_gmt":"2020-06-25T23:23:30","guid":{"rendered":"https:\/\/elzero.org\/?p=4344"},"modified":"2020-06-26T02:23:30","modified_gmt":"2020-06-25T23:23:30","slug":"js-oop-constructor-function-trainings","status":"publish","type":"post","link":"https:\/\/elzero.org\/old\/js-oop-constructor-function-trainings\/","title":{"rendered":"Constructor Function Trainings"},"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  Constructor Function\r\n  60% To 70%\r\n  Trainings\r\n*\/\r\n\r\nfunction User(name, email, age, showEmail) {\r\n  this.name = name;\r\n  this.email = email;\r\n  this.age = age;\r\n  this.updateName = function (newName) {\r\n    if (this.age > 18) {\r\n      this.name = newName;\r\n    } else {\r\n      console.log(`You Cant Update Name Because Of Age Restriction`);\r\n    }\r\n  };\r\n  this.showEmail = function () {\r\n    if (showEmail === true) {\r\n      return `Email Is: ${this.email}`;\r\n    } else {\r\n      return `Data Is Private`;\r\n    }\r\n  };\r\n}\r\n\r\nlet user1 = new User(\"Osama\", \"o@nn.sa\", 19, false);\r\nconsole.log(user1.name);\r\nuser1.updateName(\"Ahmed\");\r\nconsole.log(user1.name);\r\nconsole.log(user1.showEmail());\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-4344","post","type-post","status-publish","format-standard","hentry","category-javascript-oop"],"_links":{"self":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/4344","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=4344"}],"version-history":[{"count":1,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/4344\/revisions"}],"predecessor-version":[{"id":4345,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/4344\/revisions\/4345"}],"wp:attachment":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/media?parent=4344"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/categories?post=4344"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/tags?post=4344"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}