Solo lectura

Google Chrome - Foro de ayuda

Esta página web es un archivo de los hilos antiguos de los foros de Google. Más información

Javascript

Luis Campodonico
2/10/14 8:32
1) Escribe versión de Google Chrome (chrome://version/): 37.0.2062.94 (Build oficial 290621)  
2) ¿Se reproduce el problema en una ventana de incógnito? Control+Mayúsculas+N 

3) Adjunta una captura de la pantalla de tu problema/error/incidencia:   



4) Describe detalladamente el problema:

Hello! group.

I'm having a trouble while scripting,when applying poo in a javascript viewpoint.

This is a minor approach to my class:

function Test( ){};
Test.prototype.$field = [];

Let's suppose this class has only a field, that field is an array, let's then create two objects, a and b accordingly:

$a = new Test();
$b = new Test();

Printing the fields, nothing seems odd still:

console.log($a.$field); // Prints []
console.log($b.$field); // Prints []

Loading an array inside the first position of the first object causes the second object to be populated with same data:

$a.$field[0] = ["a", "b", "c"];
console.log($b.$field); // Prints ["a", "b", "c"]

This does not happen if the assigned value is not an array:

$a.$field[0] = "Test";
console.log($b.$field[0]); // Prints undefined

I'm using Google Chrome, Linux, Ubuntu 12.10, maybe the trouble could be my os version, or my computer itself (in case this were a bug), if it is a feature, i honestly don't understand it.

I am interested on having it working on a Google Chrome, if someone can have it working then i can guess a solution depending on the context.

Thanks in advance, and sorry my english, in case.

Respuestas (1)

Dennis Tobar
2/10/14 11:14
Luis:

I'm debugging your code and it shows this (in Windows 7 and Chrome 37)

As I understand, the undefined value comes from function's return.

You could contact the Chromium developers if you think this is a bug in the V8 Javascript implementation (see crbug.com).

Regards

(If you are a Spanish speaker, you can talk us in Spanish, ¿de acuerdo? ;))