Use this tag for questions related to and particular to javascript-objects.

learn more… | top users | synonyms (1)

1
vote
4answers
40 views

Can an array in javascript ever be deleted?

I am going through the process of creating a bunch of array's , adding elements with push() and getting back a few arrays with a bunch of elements based on the process used to get the elements on the ...
0
votes
3answers
33 views

How to create new JavaScript class based on an existing class and extend it

I am learning JavaScript and am little confused on how to create new JavaScript class based on an existing class and extend it. I have a Person class which, I have created 2 instances from (John and ...
1
vote
1answer
19 views

String can be assigned to undefined, but not object property

Using NodeJS and MongoDB. I have a mongo query and I am trying to assigned some of the properties of my query to an existing Object, which was the result of a previous query. I am getting ...
1
vote
2answers
30 views

Javascript objects with number property in prototype

Can anybody help me understand why the "counter" property seems to get reset on every new instance? I expected it to work like the "letters" property, which is shared across all instantiated objects. ...
0
votes
7answers
28 views

How do I set a base object's defaults?

I am new to JavaScript and trying to get my head around object constructors vs prototype when defining the base object's properties and methods with defaults. // base object function Animal (nameArg, ...
0
votes
4answers
43 views

Why can't I set a JavaScript function's name property?

I am learning JavaScript and read that functions are like objects and can have properties set like this: var person = function(){ } person.name="John Smith"; //output "" person.age=21; //output 21 ...
0
votes
1answer
30 views

Creating an array object within an array object

I have an array object that needs another array object added to it. So i have details of the object that need the rows in a table to be added to that object as an array. I have tried a few suggestions ...
0
votes
1answer
54 views

Javascript JQuery code design problems

Hello to all js experts! I am trying create some skeleton to help me easy develop my code. After reading some solusions I created something more suitable to my needs: (function ($, a) { ...
0
votes
1answer
26 views

Javascript Singleton communication definition required

I made a object to keep my functions became singleton, using that, i made sample methods to call and communicate each other.. but i don't get any appropriate results.. any one correct me, the ...
2
votes
3answers
48 views

Mongoose/MongoDB result fields appear undefined in Javascript

Is there something that I'm missing that would allow item to log as an object with a parameter, but when I try to access that parameter, it's undefined? What I've tried so far: console.log(item) => ...
0
votes
1answer
42 views

Angular custom module - “object function(){…} foo has no method 'bar'”

I'm trying to create a custom wrapper for $http in angular. Here's the code outline: angular.module('jotted_resource', ['ng']) .factory('jotted_resource', ['$http', 'communicationStatus', ...
3
votes
2answers
25 views

Javascript issue with object type in IE

There is a strange issue with IE-8 I have ! I have 3 javascript files in my project This is my code in first JSFile1: function validate(p){ return p !== undefined; } and this is my second file ...
0
votes
1answer
23 views

jQuery object array get an item as jQuery object

I have an array contains jQuery selectors : var aa = $('a'); when this line fires, contains of aa is an object array filled with [object HTMLAnchorElement], now I want to get an object from aa as a ...
0
votes
2answers
72 views

how to create Object key & value in JavaScript dynamically from array string

I want to create a JavaScript object dynamically from two arrays of strings. One array is used for the key and another for the value. e.g. it should create *element.name="xyz";*etc var ...
0
votes
4answers
40 views

Variables in function must be public if need change them?

For example: function foo() { var bar = "", obj = {}; obj.change = function(key, val){ // how change bar? return obj; } return obj; } foo().change("bar", "foo"); If bar will be ...
0
votes
2answers
51 views

javascript's different extend methods

What is the difference between extend methods in JavaScript? Let's say we have the following classes: var BaseClass = function() { this.class_name = 'BaseClass'; this.foo = function() { ...
0
votes
1answer
40 views

Return random word from a dictionary object with Javascript

I'm creating a Japanese text game, しりとり Wiki, where the PC gives a word and the user must give a word the first character matches the last character of the PC's word and vice versa. GitHub Repo The ...
0
votes
2answers
40 views

Javascript override of jQuery (or any other object's) method

In this jsfiddle, the author writes a test for some custom knockout binding. As part of the test, it seems that he/she extends jquery. Is my understanding of line 30. $.fn.on = function(event, ...
0
votes
2answers
44 views

How to convert object literal to function

Is there any dynamic way to convert/clone this object: var object = { a: 2, b: function(){ return this.a; } } Into this kind of function object: function object(){}; object.a ...
0
votes
1answer
37 views

JavaScript, overwrite object without losing reference

Application I am working on a simple web application that is built on top of AngularJS. The application should be able to work offline as well as online. When the user is offline, the changes to the ...
0
votes
1answer
42 views

Javascript D3.js Manipulating arrays of objects

I'm not very experienced with javascript or D3.js and need some guidance. I have two data sets (arrays of objects) that I'd like to join. I'm trying to line up the National Average Scores with the ...
0
votes
2answers
96 views

How to copy JavaScript object to new variable NOT by reference? [duplicate]

I wrote a quick jsfiddle here, where I pass a small json object to a new variable and modify the data from the original variable (not the new variable), but the new variable's data get's update ...
0
votes
1answer
53 views

Google Chart: java.lang.NoClassDefFoundError: com/google/gwt/core/client/JavaScriptObject

I try using Google Chart to display the trendlines, based on some datas generated from the .java files. My basic idea is to create a DataTable in java file, and then I pass this DataTable to web pages ...
1
vote
1answer
70 views

Handlebars nested objects

I am using backbone.js with nested models. The idea being self-contain all attributes of the author as well as to re-use the author model on both posts and comments. At least in theory this makes ...
0
votes
4answers
36 views

call javascript object properties [closed]

This is probably a very easy question but let's say I have a php json_encoded javascript object of this form: var js_objet = { "1": { "Users": { "id": "14", ...
0
votes
2answers
49 views

Javascript deep search and change in object

I have a javascript function what is dig through on object and make a string value to function object. Have this JSON: { "active": true, "icons": { "activeHeader": "ui-icon-alert" }, ...
0
votes
2answers
37 views

Creating Javascript objects automatically and storing it inside another object

So I'm wanting to create a javascript function that is able to generate names and then set it as an variable to then create an object with. In the code below I thought up an example of entering a ...
1
vote
1answer
38 views

JavaScript Revealing Prototype Pattern - Assigning XML Data to an Object Variable

Introduction I'm building world-wide conference room directory using a XML data set. I want to tuck the data in the this.formData so that I can reuse that info in multiple ways without having to ...
0
votes
1answer
33 views

Access properties in sub object in javascript [duplicate]

I wrote a simple test script in fiddle: http://jsfiddle.net/resting/qfCue/ What I'm trying to do is to set the margin property as 2, and let obj.foptions.labelMargin and obj.marginClone take in this ...
1
vote
2answers
37 views

how to reach a property in nested objects easily?

I have a nested object. here it is: var Obj = { a: { state: { started: false, players: [], hand: 0, totalHand: 0, teams: { ...
0
votes
1answer
41 views

How to access properties of object from inside the object?

Just a basic function like the following, extended using prototype var settings = function() { this.a = 2; this.b = 3; this.over = function() { console.log('over'); }; }; ...
2
votes
1answer
46 views

Getting objects “value” in an array

I am creating a blackjack game where my deck consists of objects(cardname: value) within an array. I am wondering if there is a function for javascript objects where I can get an objects value (in my ...
0
votes
2answers
61 views

Sorting in javascript [duplicate]

Here's an example of the array that I want to sort looks like. [ { nums: 'http://s3.amazonaws.com/1375304393109.png', variant: { name: 'original' } }, { nums: ...
0
votes
3answers
66 views

How do I arrange these objects by their number properties in arrays

var person = function(name,video,twitter,facebook,number){ this.name=name; this.video=video; this.twitter=twitter; this.facebook=facebook; this.likes= number; ...
0
votes
3answers
26 views

How do I reference the object from within a $.post() call

I've got a Javascript object that looks like: var MyObject = { func1 : function() { // Does something }, func2 : function() { // Send an AJAX request out $.post('', ...
0
votes
4answers
56 views

How can i access the objects variable inside an objects function (javascipt)?

(function () { var id="test"; $.ajax({ context: this, url : "http://weather.yahooapis.com/forecastrss", success : function(data){ this.id = "was test"; ...
0
votes
6answers
55 views

difference in defining functions : JavaScript [duplicate]

Do we have any difference between the two mentioned function declaration in JavaScript //Declaration 1 var foo = function(){ // code goes here } and //Declaration 2 function foo(){ // same ...
0
votes
3answers
74 views

Javascript: Parse array like search querystring

This is a string i have in my javascript var searchString = ...
0
votes
2answers
161 views

Converting json array into variable names/ values from nested form data to repopulate form

Hopefully I can explain this properly. I have a form that gets converted to nested json from grouped form elements such as <input type="checkbox" name="faults[slats][]" value="cracked"/> ...
0
votes
2answers
47 views

JavaScript: assignment to an object within an array changes the value of all objects in the array

I have an object which have an array to hold all the children of this object, the children are also instances of the same object (I need this for a tree like structure where the object is a node of ...
1
vote
7answers
92 views

Adding php loop data to js array

I have a php loop that loops through products and their data: <?php foreach ($this->products as $product) { ?> <script type=text/javascript> product = { id: ...
0
votes
3answers
33 views

When I initialize an array with an object in JavaScript, does the array contain a reference to the object or is it passed by value?

I am using JavaScript. I have an object. I then place that object inside an array that I initialize. I then do some work on that array and the value(s) inside it. I'm hoping to know if, by changing ...
1
vote
1answer
26 views

Understanding [options] argument in Backbone.sync method

I'm working on BackboneJS project and I need to override Backbone.sync I was looking for code example and I found this. Backbone.sync = function(method, model, options) { options || (options = ...
1
vote
2answers
23 views

create a map out of list of objects using a key found in the object

Essentially I have an object like so - var data= [ { id: 1, objectType: 'Workstation', isUp: true }, { id: 2, objectType: 'Workstation', isUp: true }, { ...
0
votes
3answers
42 views

javascript object literal, combining values of objects within same literal

I am trying to create a new object from looping through the below and combining values of objects that have like types? so I have something like this: var data = [{ transID: 123, ...
0
votes
1answer
25 views

Selecting Properties from Objects 2 layers down in an array

So here's what I am working with: var Data = [Obj, Obj, Obj] var Obj = { string1: 'string', string2: 'another string', string3: 'different string', object: { prop1: 'property', ...
2
votes
1answer
36 views

accessing javascript object from function

Why does first work and not the latter?? *its only a minor difference where in the latter case i used the shorthand for accessing cats object property. I read that it shouldn't make any difference if ...
0
votes
1answer
55 views

JS object toString() returns constructor.name and data which I cannot retrieve in any other way

My question is Adobe JS specific but I am almost sure its relevance is more general. To begin, please consider the particular case: Adobe JS API for 3D has an object called Matrix4x4. In the API ...
0
votes
1answer
16 views

Accessing a function define within a function from outside

I have some code whose structure I cannot change. And functions defined in such a manner. var Something.someFunc = function(e){ function funcTwo(){ } ... ... ... ... } I ...
0
votes
1answer
47 views

javascript prototype constructor and instanceof

When I checked instanceof method, the results are not same . function A(){} function B(){}; First I assigned prototype ( reference ) property , into A A.prototype = B.prototype; var carA = new ...