Use this tag for questions related to JavaScript objects.
0
votes
0answers
12 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
20 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": [
...
0
votes
1answer
20 views
How do I simplify this reducer?
I am building a small app for adopting different types of pets.
My api looks like this
pets: [
{category: 'dog', pets: [{breed: 'chihuahua', gender: 'm' }, ....]},
{category: 'cat', ...
0
votes
0answers
17 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
13 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
105 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
33 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
53 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
80 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
73 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
52 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
56 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
32 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
101 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
29 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
57 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 ...
2
votes
2answers
30 views
Canvas Game Architecture: Access parent function in JavaScript Object
I am trying to understand how can I create a custom game object in javascript.I am working on canvas and I thought that I can create a general game object that includes information about objects ...
0
votes
5answers
54 views
for in loop in jscript object is displayed as text
var Product = {
name : 'Soap',
brand : 'Dove',
price : 25.50,
discountRate : 5,
quantitySold: [10,5,25,8,4],
netPrice:function(){...
-1
votes
3answers
57 views
compare an array that has an object
How do you compare two arrays, especially if the first array is an object with multiple parameters?
truthCheck([
{ "user": "Tinky-Winky", "sex": "male" },
{ "user": "Dipsy", "sex": "male" },
...
-1
votes
5answers
59 views
How can I return the property values of a nested JavaScript array nested in an object from JSON?
Given a JS array containing many objects which all contain arrays:
var data = [
{id: 1, name: "Fred", pages:[{url:"www.abc.com", title: "abc"}]},
{id: 2, name: "Wilma", pages:[{url:"www.123....
0
votes
0answers
31 views
Use reduce to get certain values in many arrays nested in a larger array nested in an object
I am trying to return two values from each nested array in a larger array which are all inside of an object. I need to return two values inside of pages (array) for EACH category (parent array) on ...
0
votes
2answers
28 views
How to prevent object properties to not be extended in javascript
Im trying to seal an object property .
My question is ,here i have given Object.seal(personObject),this particular object is sealed and does not allow to configure or make any extensions in this ...
0
votes
0answers
60 views
Retrieve JavaScript Object as Java HashMap via GWT JsInterop
For example i have a JavaScript object like this:
var map = { "key1" : "value1", "key2" : "value2", "key3" : "value3", ... }
In JavaScript i'm writing to it via map["newKey"] = "newValue" and read ...
0
votes
2answers
43 views
How to test a Javascript object property when function with mocha, chai
Trying to test a Javascript object
Game.js
var GameManager= {
gameType: 'room',
roomDimension: [10,10],
playerDirection: ["W"]
possibleDirections: ["N","E","S","W"],
init: ...
0
votes
0answers
26 views
Enumerability in JS Objects; Objects Without Keys
Question:
What is this object I'm getting in the console in the large photo below? It contains data, but only if I click on it in the console. I am not able to iterate over it with (for thing in obj)...
0
votes
0answers
23 views
Handlebars template in combination with javascript object
I'm trying to create a template that iterates through JavaScript objects with Handlebars.
My current object looks like this:
var countries = {
"USA" : {
"Alabama" : {
"Birmingham" :...
0
votes
2answers
44 views
Object.prototype and Function.prototype
In JS functions are said to be objects. Now when functions are tested against objects, they behave differently.
a = {};
console.log(a.prototype); //undefined
function myFunc() {};
console.log(...
0
votes
5answers
36 views
Fill an HTML table with a Javascript Array with objects
im new to coding and to this community and i really searched for the answer i wanted but found nothing this specific. So here goes :
i have an array that goes like this :
var arr = new Array();
arr[...
0
votes
1answer
40 views
Javascript: Updating direction of robot using string is not working
Javascript
Trying to work on a simple game of moving a robot using key L(to move left), R(to move right), F(to move forward) from a specific position on a board where it is created using 5x5 ...
1
vote
2answers
45 views
Getting url from file location using Javascript
I have a slider that uses an html file in a frame on SharePoint. Slides are changed quite frequently and this slider is being rolled out 10 more times. I am wanting to create a workflow so the end ...
2
votes
2answers
38 views
Callback for find not working-Javascript
I have written a custom callback function for Javascript's find function
but that is always yielding undefined
var objectsArray = [
{ 'a': 1, 'b': 2, 'c': 3 },
{ 'a': 41, 'b': 5, 'c': 7 },
...
0
votes
0answers
13 views
AngularJS 1.5.8 - propsFilter with Parse Object
Is there any way to use the propsFilter, for example, with ui-select with a Javascript object (I have a ParseObject from the open-source Parse server). My existing code is:
<ui-select ng-model="...
0
votes
1answer
37 views
Javascript - Property of an object has the value of NaN, even when I explicitly assign it a number value
I am making a basic platform game in my spare time, and I am currently trying to add gravity. The game runs in a canvas, and so I am using black pixels as solid objects. The sprites I am making are ...
0
votes
2answers
29 views
Finding the object's name using the constructor's argument's values
So using the following part of my code, I've been trying to find the object's name ("object's name" refers to foo, bar, baz, and jar below. Sorry if that's the improper term, couldn't find any ...
0
votes
1answer
18 views
ES6 call with variable inside array that is inside an object with multiple objects or properties
Took me a lot of time to frame the title, alas it's still hard to comprehend.
Anyway this is what I wanna do, but don't know how to do it, or whether it is even possible, so please enlighten me.
...
0
votes
2answers
33 views
Accesing the object's property form a nested function [duplicate]
Here is my java script code.
var fiat = {
make: "Fiat",
model: "500",
year: 1957,
color: "Medium Blue",
passengers: 2,
convertible: false,
mileage: 88000,
fuel: 0,
...
0
votes
3answers
39 views
Lodash / javascript : Compare two collections and return the differences [duplicate]
I have two array of object :
the element of my table are not primitive value, but complexe objects.
array1 = [obj1,obj2,obj3,obj4]
array2 = [obj5,obj5,obj6,obj7]
I would like to compare two arrays ...