Use this tag for questions related to JavaScript objects.

learn more… | top users | synonyms (1)

0
votes
1answer
11 views

JavaScript Object Literal “this”

I wrote a JavaScript object literal to handle multiple modals on a HTML page. When I click on a buttton to show the Modal, I'm getting the following error. Uncaught TypeError: this.showModal is not ...
1
vote
0answers
28 views

What Is the best way to access and organize instances of class objects in JavaScript?

On document.ready, let's say i loop through and I instantiate a bunch of front end Car objects based on existing div element ids. For example my divs would look something like this <div id='...
-3
votes
0answers
19 views

Javascript: ExtendObject takes in an object, property, and value as parameters [on hold]

ExtendObject takes in an object, property, and value as parameters and adds the property and value to the object. If the property already exists, overwrite its current value with the new value. Return ...
1
vote
4answers
39 views

JavaScript items missing from Object I just created

I've created an object in JavaScript and for some reason it's not saving the 17th and 20th items in the object. You can see what I mean with the below code, the 17th & 20th items are not logged ...
3
votes
4answers
44 views

Summarize count of occurrences in an array of objects with Array#reduce

I want to summarize an array of objects and return the number of object occurrences in another array of objects. What is the best way to do this? From this var arrayOfSongs = [ {"title":"Blue","...
1
vote
1answer
19 views

How to define filters in plupload

I use plupload. Plupload allows me to select files which extensions did not defined in settings. For example I can select and upload .rar or .txt files. But I do not define these extensions in filters....
-3
votes
0answers
30 views

IE11: Invalid Argument script warning issue webpage SharePoint 2010

An error has occured in the script on this page: Error-Invalid argument. Line 2 char 67376 Encountering Script error windows prompt when accessing webpage. Debuuged Screen shot of the init.js ...
3
votes
1answer
40 views

Error when using the spread operator in objects with optional property

I want to turn initial data into working data. Both have its own type, the only difference is that in the initial data, the names are optional. When I'm creating the working data, I use default value '...
2
votes
1answer
25 views

How to access a nested object with string paths? [duplicate]

I'm trying to access properties of a JavaScript object by passing a path (string or otherwise): // In a loop tableData[i].profile.firstname where 'profile.firstname' is the path. Is there a way to ...
-5
votes
1answer
25 views

When is it appropriate to create a static property instead of an instance in javascript objects?

I don't really understand how/when to use javascript prototypes. I understand the difference between these two ways of assigning properties: Static property var Date = function () {}; Date.setTime = ...
1
vote
0answers
16 views

Add bin number for accessory product onto the packing slip - Bigcommerce

I have exhausted all the resources I could think of, between their community forum and their support staff, I can't get a hint. The Scenario: A person chooses a product to buy. When they click 'add ...
1
vote
1answer
55 views

How can I console.log only if result is or isn't found?

I'm creating a mini-search tool for a learning project and I can't figure out why this console.logs both times var states = { North_Dakota: {capital: 'Bismarck', region: 'Mid-west'}, Minnesota: {...
-3
votes
0answers
38 views

What does Object2 && Object1 do here? [duplicate]

Can someone explain to me what this third line does? var Object1 = [{"name":"FirstObject","last":"F"}]; var Object2 = [{"name":"SecondObject","last":"S"}]; Object2 && Object1 It returns ...
1
vote
4answers
29 views

Filter array based on dynamic parameter

Say I have an array of json objects which looks like below: var codes = [{ "code_id": "1", "code_name": "code 1", , }, { "code_id": "2", ...
0
votes
0answers
15 views

using angular drag and drop lists with angular filter groupBy and toArray

I have a list of items that I put through a number of angular filters to select them on various criteria and then finally group them by a particular property/field to create a series of lists with ...
0
votes
3answers
52 views

JSON.parse with reviver function returns undefined

I am new to JSON and getting this exception while using reviver parameter in JSON.parse(): TypeError: Cannot read property 'name' of undefined(…). Without reviver parameter code works fine but with ...
0
votes
1answer
22 views

how to edit javascript Objects with loop (Jvectormap)

I'm new to Javascript objects and Jquery and I have no clue how I do something like this: series: { regions: [{ values: { ...
-1
votes
1answer
31 views

How do I create Objects in Javascript, so I can later access their properties?

I am filling an array with objects using this code: orders.push(getOrder(orderName, sender)); ... function getOrder (orderName, sender){ this.orderName = orderName; this.orderDate = ...
2
votes
1answer
24 views

How to show code external JavaScript in alert?

How to show code external JavaScript in alert or anywhere because is value of variable s_code (function(){ var newscript = document.createElement('script'); newscript.type = 'text/...
0
votes
2answers
55 views

how to stop the setTimeout counter from another function call through button click

I am creating an sample application, user signout time is 15 minutes. Before 2 minute, users gets an pop with warning message with countdown. There are two buttons. 1) Logout => for logout. 2) ...
-2
votes
1answer
38 views

How to debug JavaScript code?

var myObject = { name: function() { return "Michael"; }(), age: 28, sayName: function() { alert(this.name + ":" + this.age); }(), specialFunction: function() { myObject = this; ...
0
votes
1answer
28 views

Resetting a class parameter upon new instance of that class: JS ES6

I am working on creating a game that redraws the canvas every time the player goes to a new "room". While most of the functionality is there, I am having some trouble with the player... although the ...
-1
votes
1answer
28 views

Javascript Profile Lookup function

Here is what I want to achieve: *The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact. If both are true, then return ...
-1
votes
0answers
32 views

How to get JSON array/object data [duplicate]

I'm stucked with javascript, i need to get this data items->NYC->labels ([November,October,September]) JSON looks like this: { "items": [ { "NYC": [ { "students": [ ...
-2
votes
3answers
64 views

Is searching for a value to delete inside a reducer considered a good practice? [closed]

I am building a small app for adopting different types of pets. My API looks like this: [ {category: 'dog', pets: [{breed: 'chihuahua', gender: 'm' }, ....]}, {category: 'cat', pets: [...
0
votes
0answers
18 views

What is the correct use of namespaces is a javascript application?

I recently started a new project. And in order to improve my JavaScript skills I decided to write my code using namespaces (object based). I decided to use this pattern only because I found it ...
0
votes
5answers
40 views

Javascript object get value above

I have an object like this: var structure = { "root":{ "name":"Main Level", nodes:{ "node1":{ "label":"Node 1" }, "node2":...
1
vote
0answers
14 views

Mapael update trigger

So essentially I am working with a large dataset and don't want to have to define every area for every year. But when I update to the next year it only appends the data to the map leaving the rest ...
1
vote
1answer
106 views

Why are the values in my inner object blank?

I am just trying to get a JSON output like this { "SW Reqs or Problem Analysis & Estimate": { "Estimate_Days": "I", "Performers": "am", "Percent_Done": "so", "Work_Done": "...
0
votes
1answer
28 views

Potential dangers of enabling classwide globals (Javascript)?

I have a question regarding the relative safeness of designing Javascript types that use class static/global variables. For example, suppose we had: function whatever() { if(whatever.initialized =...
-1
votes
1answer
25 views

JavaScript constructor accesses prototype but breaks inheritance

What I want to do is to define (construct?) an object myObj that has a per-instance property id increments a property shared among all instances count puts a copy of each instance into a shared array ...
0
votes
1answer
18 views

Rendering both property value and property name of a JS object using .map()

Basically I need to render an object into a react component. It looks something like this: var obj = { prop1: "prop1", prop2: "prop2", prop3: "prop3", } I just want to print out both the ...
0
votes
0answers
34 views

When it is a number display text center else display text left

The numbers must center align and the text must left align Im getting a error in my code. Can anyone tell me what am I doing wrong Image Code color = color !== "" && color !== ...
0
votes
3answers
55 views

How to check if value is a number

How to check if value is a number. If it is a number value display text center else text left. I want to know what is wrong with my statement. for (var l = 0; l < Object.keys(pods[i].data....
0
votes
0answers
17 views

javascript dirReader iterates over entries, finds files and folders, sets booleans, but they return to false after the for loop

I have the following javascript code processEntry = function(entry){ var dirReader = entry.createReader(); var hasFolders = false; var hasFiles = false; ...
3
votes
2answers
81 views

Method to declare Javascript objects without the “new” keyword kosher?

I've been been learning Javascript over the past few months, and sometimes get the feeling that I'm writing code faster than I actually grasp the nuances of the language, so please bear with me here. ...
1
vote
0answers
74 views

How to handle the countdown with setTimeout and Interval in javascript

I have worked in capturing the user in the application, after login. After login I capture the users session with JavaScript's interval functions The Interval functions trigger every minute. when ...
0
votes
2answers
54 views

Comparing certain key, value pairs within an object - No Direct Matches (JavaScript)

I am currently building a simple sales management tool for the sales reps team. I am very extremely new to programming but have enough knowledge in JavaScript to understand the basic concepts and ...
0
votes
2answers
88 views

How to add char to javascript object keys and values?

I am trying to add '_x' to every object key and '_y' to every object value. This is the code: var data = { "glossary": { "title": "example glossary", "GlossDiv": { "title": "S", ...
-1
votes
1answer
39 views

Building JSON with array elements array values are undefined

What i am trying to achive is values are sent to via REST message, i am trying to place these values in a JSON format, so they can be placed into a field on a form. var membersToAddArry = []; ...
2
votes
3answers
58 views

How create static functions/objects in javascript/nodejs (ES6)

I want to create a static class using Javascript/Node JS. I used google but i can't find any usefull example. I want to create in Javascript ES6 something like this (C#): public static MyStaticClass ...
1
vote
4answers
30 views

How to populate associative array through for loop

I need to create this kind of element inside my array: { Field1: "2011/04/23", Field2: 8, Field3: "Adam", Field4: "Den"}, { Field1: "2011/03/25", Field2: 6, Field3: "Honey",Field4: "Singh"} ...
-1
votes
3answers
40 views

Sorting array of objects based on date

I have an array of objects similar to... [ { date: "26/11/2016" hourlyRate: 50 hoursWorked: 10 name: "Mr G" natInsNumber: "GG845893G" }, { date: "14/10/2016" ...
0
votes
1answer
34 views

Evaluate object expressions without using eval

How can i evaluate js object expression without using eval. For examples 'd3.scale.category10().domain(d3.range(m))' 'd3.range(n).map(function() {//body})' i want to get the output like var a =...
2
votes
3answers
54 views

JavaScript - Insert & Remove a element in object

I have a object. var dl_items; After a loop for inputing data: dl_items[code] = itemObject; I have a array: dl_items : { "code_A" : { "index" : 1, "status" : 2, "name" : A_data}, ...
4
votes
4answers
102 views

Difference between assigning an object to undefined and delete

I was reading Secrets of the JavaScript Ninja and came across a coding example: var ninja = { yell: function(n){ return n > 0 ? ninja.yell(n-1) + "a" : "hiy"; } }; var samurai = { ...
1
vote
1answer
30 views

Check if an object exists twice in an array

I have an array containing objects with this structure: var results = [{ AuthorId: 2, Id: 89, caseId: 33 //some key },...]; Now, I want to check if the objects in this array exist 2 or ...
0
votes
1answer
69 views

Javascript Object with a variable

I'm building a basic game with NSEW navigation. Each NSEW button changes the current location's number, 1,2,3,etc. Each location has an object that's intended to be associated with it, named ...
0
votes
2answers
58 views

Finding the number of elements in a json object

I can't figure out how to find the number of elements contained in a JSON object with JavaScript. This is how my object is structured: var shows = []; //make http call here to api url and store in ...
0
votes
2answers
39 views

how to reduce the time counter in javascript

Need to reduce the timing for the set times Eg) user logout time is 14:23:30 means need to show the remaning time seconds to the user. need to show the counter reducer time in javascript. Here is ...