Use this tag for questions related to JavaScript objects.

learn more… | top users | synonyms (1)

-1
votes
1answer
48 views

asynchronous javascript isn't synchronous it doesnt wait for array processes complete on drop event

Problem is below I have a arr_x array.And I call "call_when_drop" function like below <body ondrop="call_when_drop(event,this);" ></body> Then it begin to create array elements.when I ...
0
votes
0answers
17 views

How to simulate a dataTransfer object? [duplicate]

I would like to simulate a file drop on a window. I can replace the File object with a Blob. To launch the event, I use zone.dispatchEvent(new DragEvent('drop', {dataTransfer: __________})) The ...
0
votes
1answer
23 views

understanding prototype or Map.prototype in javascript [duplicate]

understanding Map.prototype javascript Hi all... I have gone through many example and tutorials to understand what Map.prototype actually represents.. in some blogs i saw that it represents Map ...
0
votes
1answer
44 views

Vending Machine not returning change

This is a Code Wars kata: Vending Machine Here, I'm trying to simulate a vending machine. So far, I can return coins if the credit inserted is not enough, and I can get the machine to tell me how ...
2
votes
3answers
61 views

Could you explain me this block of code? (Contact List)

I'm studying JavaScript on my own and I started by reading tutorials and books (like Eloquent) and articles (on Medium for example). I'm also doing some free courses, two in particular: freeCodeCamp ...
0
votes
1answer
29 views

Output my JSON data before I use Firebase $save or $add in console?

I've been trying to debug for hours a Firebase rule problem and was wondering if there is something easier available. My problem is that I save my firebaseObject with $save (or create with $add) and ...
-2
votes
2answers
34 views

How to create new object in javascript from variables? [on hold]

I am having problem with creating the new object. I have this constructor: var persons = []; function Person(first, last, age) { this.firstName = first; this.lastName = last; this.age = ...
-1
votes
3answers
37 views

Javascript: How to cancel out a setTimeout function?

I am making a boon system where the player gets a random boon/buff for 30 seconds and then it removes itself. I have the initial boon in place where it lasts 30 seconds, then removes itself. I push ...
-1
votes
1answer
32 views

Json multiple array of objects [on hold]

I'm new to json, I want to accept array of objects. My json format var my=[ { "name":"A", "size":39, "imports":[ "B", "C", ] } how to accept dynamically.Please help me
-2
votes
0answers
31 views

Should front end JavaScript classes/model objects match back end classes/models? [on hold]

When I retrieve object model properties from my backend and then build front end interface elements from that backend data, should my JavaScript class objects match my back end models for the most ...
0
votes
0answers
18 views

Sequelize Pulling data from multiple tables and passing as objects to render in EJS

am new to Node Js and associated programmes. Currently trying to create an app which uploads images with captions etc and for users to like and comment (more like instagram/facebook). So far my app ...
0
votes
0answers
19 views

What is difference between function(){} and ()=>{} [duplicate]

I am new to Javascript and was reading an article about the javascript events and found that in the article the author used '()=>{}' instead of 'function(){}' for event handlers. So i want to know ...
0
votes
2answers
22 views

Why its returning undefined ? What is the scenario?

When passing 'y' through the function argument it returns undefined but without argument it returns the valid value, But why its returning undefined when passing through argument ? var y = 'Hello ...
0
votes
1answer
17 views

JavaScript Object Literal “this” [duplicate]

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
30 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='...
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
48 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
1answer
43 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
26 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
17 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
56 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
39 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
32 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
53 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
24 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
56 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": [ ...
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
16 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
82 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
75 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 = []; ...