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
1
vote
1 answer

Object.create and private functions in modules

This is a standalone implementation of ES5's Object.create: window.createObject = (function() { var F = function () {}; return function(o) { F.prototype = o; return new F(); } }()); and an example of its use: var cat =…
Matty F
  • 3,763
  • 4
  • 30
  • 48
1
vote
1 answer

JavaScript: get & set nested attributes of an object

There are questions and answers on how to get & set nested attributes/properties on an object in JS around the net & StackOverflow as well, but none so far fit my problem, so here it is. The code that declares/defines the object is /** * a dummy…
yogmk
  • 161
  • 10
1
vote
2 answers

Any cases when an object does not traverse its prototype chain to get value?

As we know, when we try to access an object's property it first check's if the object has its own property. If it does not find, it traverses the prototype and checks, and so on up the prototype chain. Coming to the question, please check the below…
1
vote
0 answers

Why below code compiles fine and prints "init"?

System.out.println("init"); this statement is not within static block and not in any function or constructor, but still java doesn't give any error or warning and prints it before constructor sysout. why ? public class A { public A() { …
Ajinkya
  • 125
  • 7
1
vote
4 answers

Java object creation difference

I'm new to OOP concepts in Java. What is the difference between these two incidents? 1. ClassName obj_name = new ClassName(); obj_name.method(); 2. new ClassName().method(); A good explanation is much appreciated. Thanks
wr93_
  • 130
  • 1
  • 1
  • 13
1
vote
2 answers

Is it possible to use the Object.create pattern to create a CustomEvent object?

I know you can create a CustomEvent like this: var wordCreated = new CustomEvent( "newWord", { detail: { word: "hola", translation: "hi", }, bubbles: true, cancelable: true …
user2467065
1
vote
2 answers

What does it mean to call Object.create(new EventEmitter) in Node.js

I've read the MDN document on Object.create. It only pointed out the scenario when the first argument is a prototype. However, I've seen some code in Node.js like this: var events = require('events'); var emitter = new events.EventEmitter(); var…
LASkuma
  • 119
  • 1
  • 6
1
vote
3 answers

javascript - Object.create explanation

I have a question about the following canonical object.create method: Object.create = function(o, props) { function F() {} F.prototype = o; if (typeof(props) === "object") { for (prop in props) { if…
dagda1
  • 26,856
  • 59
  • 237
  • 450
1
vote
1 answer

JavaScript inheritance Object.create

Ok, I'm trying to track any changes made to a huge form on a web application. When the page is loaded, I create a JS object that 'captures' the initial state of all input fields (selects, radio buttons, checkboxes etc...).When the user alters the…
0
votes
3 answers

Inheritance and Object.Create in Javascript

look at this code : var Test = { options: { name: 'foo' }, name: 'foo', init: function (name) { this.name = name; this.options.name = name; } }; var dict =…
0
votes
1 answer

Using set to change property value in a constructor, C#

The program I wrote works, and prints fine. It creates two objects fine. One object is to be created using the no-arg default constructor, and the other is to be created from the non-default constructor. The only difference is I am supposed to use…
0
votes
2 answers

Memory allocation is done before first line of constructor execution or after constructor execution - Java

Student student = new Student(); In the above code, we have created one Student class object, in that is JVM allocate the memory before the first line of constructor execution or after the constructor execution, Even after the parent classes?
Pravin Abhale
  • 395
  • 2
  • 4
  • 15
0
votes
2 answers

JavaScript delete operator and Object.create() method

I am trying to remove a property from an Person object like this: const Person = { firstname: 'John', lastname: 'Doe' } console.log(Person.firstname); // Output: "John" delete Person.firstname; console.log(Person.firstname); //…
Zuckerberg
  • 1,781
  • 2
  • 10
  • 19
0
votes
0 answers

Different between `Object.create(ctor.prototype)` and `new ctor()`

In VS Code 's source code, I found a pice of code like this: (typescript) /** * Creates a new object of the provided class and will call the constructor with * any additional argument supplied. */ export function create(ctor: Function, ...args:…
GongT
  • 131
  • 1
  • 10
0
votes
0 answers

AWS - Single email notification for multiple ObjectCreate

I'm trying to figure out how to incorporate multiple ObjectCreate() events into a single email notification instead of one email notification for each. I would also like to send it to the client once per day as a sort of daily update for each…