TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Srinivasan Amarnathan
NA
40
1.2k
usage of Object.Create
Apr 11 2018 4:45 AM
Hi people ,
var shape = function() {}
shape.prototype.draw = function () {
document.write("I am shape
");
}
var circle = function () { }
circle.prototype = Object.create(shape.prototype);
or
circle.prototype = Object.create(shape);
For inheritance, we are usually using "Object.create(shape.prototype)" .
Not able to achieve the inheritance if we use Object.create(shape);
When i entered in browser debugger.
Object.create(shape) returns ,
Function {}__proto__: ƒ ()arguments: nullcaller: nulllength: 0name: "shape"prototype: {draw: ƒ, constructor: ƒ}__proto__: ƒ ()apply: ƒ apply()arguments: (...)bind: ƒ bind()call: ƒ call()caller: (...)constructor: ƒ Function()length: 0name: ""toString: ƒ toString()Symbol(Symbol.hasInstance): ƒ [Symbol.hasInstance]()get arguments: ƒ ()set arguments: ƒ ()get caller: ƒ ()set caller: ƒ ()__proto__: Object[[FunctionLocation]]: <unknown>[[Scopes]]: Scopes[0][[FunctionLocation]]: polymorshipsm.html:10[[Scopes]]: Scopes[1]
Object.create(shape.prototype) retruns
shape {}
What is difference between Object.create(shape.prototype) and Object.create(shape)
Reply
Answers (
3
)
how to set a background image in html which fit to screen
How to Send Email Using JavaScript And Html