Questions tagged [object-create]

An alternative to JavaScript's new operator added in ECMAScript 5 and championed by Douglas Crockford.

Object.create() is an alternative to JavaScript's new operator added in ECMAScript 5 and championed by Douglas Crockford.

71 questions
0
votes
1 answer

When using Object.create() how do you reference Object keys withing other object keys

I'm trying to learn Object.create by making a contrived calculator module. I've tried bind I've tried removing this, but no results. QUESTION: How do you reference a property of an object within another property of an element like you would with a…
Armeen Moon
  • 18,061
  • 35
  • 120
  • 233
0
votes
1 answer

Why is the prototype chain being executed differently?

I'm trying to learn more about Javascript and dig a bit into the prototype chain. I wanted to create a small extension for an HTMLElement when I came across this problem. The way I understand Object.create is that the object that is passed to it is…
peinearydevelopment
  • 11,042
  • 5
  • 48
  • 76
0
votes
0 answers

Spring getBean very slow

The code below is used to create many beans and add them to a list for further usage final List> tasks = new ArrayList<>(); for (long i : manyLongs) { tasks.add((Flow) ctx.getBean("flowBeanName",…
idipous
  • 2,868
  • 3
  • 30
  • 45
0
votes
1 answer

Factory Design Pattern with only one concrete class type

Hi there I hope I am able to explain myself clear enough with this problem I have been really confused about. I have a concrete class called UTModule, it is not subclassed at all, but it is composed of several different abstract objects (for example…
AndyNZ
  • 2,131
  • 4
  • 24
  • 27
0
votes
1 answer

extending Object.create() in javascript

I'm extending Object.create() to take a second argument e.g if (typeof Object.create !== 'function') { Object.create = function (o,arg) { function F() {} F.prototype = o; return new F(arg); }; } //could be multiple…
user818991
0
votes
1 answer

Why doesn't "var derived1 = new Object(base)" set the derived1.prototype to base?

Given the following code sample: var base = { one: "one", two: 2, test: function() { return "test"; } }; var derived1 = new Object(base); function Ctor() { }; Ctor.prototype = base; var derived2 = new Ctor(); var proto1 =…
James Cadd
  • 12,136
  • 30
  • 85
  • 134
0
votes
1 answer

Javascript Object.Create copying reference to object

I have the following code ViewModel.prototype.update = function(initial) { var ittr, key, val, x; for (key in initial) { val = initial[key]; if ($.isArray(val) && $.isArray(this[key]())) { ittr = 0; while (ittr < val.length)…
DrSammyD
  • 880
  • 12
  • 32
0
votes
1 answer

Does Object.create support so called class methods?

When I create an object using a constructor like: function Person(name, age) { this.name = name; this.age = age; } I can add properties that are functions to the constructor function which act like (static) class methods. Object.create doesn't…
Fred Finkle
  • 1,947
  • 3
  • 18
  • 21
-1
votes
2 answers

Parent class reference pointing to Child class Object

I have confusion in object life cycle. If parent class reference pointing to the child class object and method is overridden. For example class Parent { public void display(){ System.out.println("i am from Parent"); } } class…
Girish
  • 107
  • 3
  • 10
-4
votes
1 answer

Javascript in Object Literal approach difference between calling a method direct and using Object.create?

Suppose this is my object // Object Literal var personObjLit = { firstname : "John", lastname: "Doe", greetFullName : function() { return "personObjLit says: Hello " + this.firstname + ", " + this.lastname; } } I…
Piyush Jain
  • 1,895
  • 3
  • 19
  • 40
-4
votes
1 answer

I want to write a function in Java that takes a String as argument and creates an object with the same name

Say I am getting names of people and want to create person objects of the same name, something like this : void foo(String str){ Person str = new Person(); } So that later I can refer to the person by name, something like : int…
1 2 3 4
5