Title: __proto__ 和 prototype · Issue #2 · K0II/JavaScript · GitHub
Open Graph Title: __proto__ 和 prototype · Issue #2 · K0II/JavaScript
X Title: __proto__ 和 prototype · Issue #2 · K0II/JavaScript
Description: Object includes a prototype linkage feature that allows one object to inherit the properties of another. 基本上任何对象都有一个__proto__,并且都不为空,不能直接修改,而函数对象的prototype属性是可以修改的 [ ES5中是Object.getPrototypeOf() ] var Person = function(name,age){ this.na...
Open Graph Description: Object includes a prototype linkage feature that allows one object to inherit the properties of another. 基本上任何对象都有一个__proto__,并且都不为空,不能直接修改,而函数对象的prototype属性是可以修改的 [ ES5中是Object.getPrototypeOf() ] ...
X Description: Object includes a prototype linkage feature that allows one object to inherit the properties of another. 基本上任何对象都有一个__proto__,并且都不为空,不能直接修改,而函数对象的prototype属性是可以修改的 [ ES5中是Object.getPrototypeOf() ] ...
Opengraph URL: https://github.com/K0II/JavaScript/issues/2
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"__proto__ 和 prototype","articleBody":"\u003cbr\u003e\n\n\u003e Object includes a prototype linkage feature that allows one object to inherit the properties of another.\n\n基本上任何对象都有一个`__proto__`,并且都不为空,不能直接修改,而函数对象的prototype属性是可以修改的\n\n[ ES5中是`Object.getPrototypeOf()` ]\n\u003cbr\u003e\n\n``` javascript\nvar Person = function(name,age){\n this.name = name || 'Down';\n this.age = age || 18;\n}\n\nPerson.prototype.say = function(){\n console.log(this.age);\n}\n\nvar person1 = new Person('John',10);\n\nperson1.__proto__; // Object {} ==\u003e Object.prototype\nconsole.log(person1.name, person1.age); // John 10\nperson1.say(); // 10\n\nvar person2 = new Person();\n\nperson2.say === person1.say; // true\n```\n\n\u003cbr\u003e\n\n``` javascript\nvar Person = {\n name: 'Down' || this.name,\n age: 18 || this.age\n}\n\nvar person1 = Object.create(Person);\n\nperson1.__proto__; // Object { name=\"Down\", age=18} ==\u003e Person\nconsole.log(person1.name, person1.age); // Down 18\n\nperson1.age = 30;\nconsole.log(person1.name, person1.age); // Down 30\n\nvar person2 = Object.create(Person);\n\nperson1.name === person2.name; // true\n```\n\n`new fn()`,生成一个对象,对象的`__proto__`绑定到被调用的函数的`fn.prototype`上\n`Object.create(o)`创建的对象,生成的对象的`__proto__`绑定到`o`上\n\u003cbr\u003e\nJavaScript: The Good Parts,[ES5标准中已经可用]\n\n``` javascript\nObject.create = function (o) {\n var F = function () {};\n F.prototype = o;\n return new F();\n};\n\nvar b=Object.create(a);\n```\n\n\u003cbr\u003e\n","author":{"url":"https://github.com/K0II","@type":"Person","name":"K0II"},"datePublished":"2016-05-23T08:42:56.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/2/JavaScript/issues/2"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d9cda433-b9bf-7a32-c8bd-e24a10d8eaa1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C6E4:25572C:8D70D32:C4EFC8C:6A502597 |
| html-safe-nonce | 7255ac8b4debfb74196d1caba4af47e4b31e83a7b84642babe444f6d2c22365e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNkU0OjI1NTcyQzo4RDcwRDMyOkM0RUZDOEM6NkE1MDI1OTciLCJ2aXNpdG9yX2lkIjoiNTY2MjYzNzc1NTYwMTAwMzkyNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d61b9b04ad324eb71747ded4351feee01bfb2920a501fa6650ade6a12e26abbe |
| hovercard-subject-tag | issue:156228109 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/K0II/JavaScript/2/issue_layout |
| twitter:image | https://opengraph.githubassets.com/73c4e086091a5334a2a6046640fd5e333422786518016957ca21f90c79bad4fe/K0II/JavaScript/issues/2 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/73c4e086091a5334a2a6046640fd5e333422786518016957ca21f90c79bad4fe/K0II/JavaScript/issues/2 |
| og:image:alt | Object includes a prototype linkage feature that allows one object to inherit the properties of another. 基本上任何对象都有一个__proto__,并且都不为空,不能直接修改,而函数对象的prototype属性是可以修改的 [ ES5中是Object.getPrototypeOf() ] ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | K0II |
| hostname | github.com |
| expected-hostname | github.com |
| None | a08040246389072795e3b4e7b33c6d9a0c564eee02e829a809326d67c418b069 |
| turbo-cache-control | no-preview |
| go-import | github.com/K0II/JavaScript git https://github.com/K0II/JavaScript.git |
| octolytics-dimension-user_id | 19141974 |
| octolytics-dimension-user_login | K0II |
| octolytics-dimension-repository_id | 57857936 |
| octolytics-dimension-repository_nwo | K0II/JavaScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 57857936 |
| octolytics-dimension-repository_network_root_nwo | K0II/JavaScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d1b91b18e7330fc458dfd824c61eaed7daa830d6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width