Use this tag for questions related to JavaScript objects.
0
votes
1answer
37 views
Javascript object property gets updated on assignment [duplicate]
I have created a JavaScript object like below -
var objtvar = {defaultPoints: [[0,0],[0,-10],[2.5, -10], [2.5, -10],[5, -10],[5,0]]}
I need to assign the defaultPoints property to another array and ...
0
votes
1answer
32 views
Different JS Namespace declarations
I wonder, are the following code example the same?
Version 1:
var myNamespace = {};
myNamespace.say = function() {...}
Version 2 (JS-Fiddle: https://jsfiddle.net/542wbkat/) :
var myNamespace = new ...
0
votes
0answers
17 views
Illustrator CS6 tracingoptions maxColors not working?
I am using extendscript to create a script for CS6.
I have reffered to the PDF here: http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/pdf/illustrator/scripting/cs6/Illustrator-Scripting-...
1
vote
1answer
21 views
Accessing 'this' inside an independent function in a Constructor
I have a Dog Constructor as follows:
var Dog = function(name,type)
{
this.name = name;
this.type = type;
this.normalObjFunc = function()
{
this.name = "kl";
}
var retfunc = ...
2
votes
1answer
28 views
JavaScript Prototype Object.create
I have two version code
let Animal = function()
{
}
Animal.prototype.voice = "Miau"
let Cat = function()
{
}
Cat.prototype = Object.create(Animal.prototype);
...
0
votes
1answer
22 views
Ionic2 private property in a class always empty even if set in that class
I'm new with Ionic2, and TypeScript and try to play with Classes, properties, getters and setters.
My first class just initialize some datas in a webSQL database and expose methods that retrieve infos,...
-3
votes
2answers
37 views
Returning an object from a function in JavaScript
I have a function that returns an object in javascript. The objects returned are instances of a "messagePack" that I want to send to the server. Each messagePack will be different. E.g.:
function ...
5
votes
4answers
60 views
Trying to understand scoping within two short JavaScript functions
What is the difference between the following two JavaScript functions? I know variables declared with var are local inside the function, and if declared withthis` keyword are exposed to outer word. is ...
0
votes
2answers
30 views
How to access object property in module.exports
I am curious about how to access another object property in module.exports.
here is the case :
module.exports = {
text: 'abcd',
index: (req, res)=>{
console.log(text) <-- ...
-7
votes
0answers
19 views
Generate an internal structure (filling) for an object defined in an .off file [closed]
Among many formats used for 3d representations of objects the .OFF (DEC object file) is one of the simplest.
a) Consider the problem of generating an internal structure (filling) for an object defined ...
1
vote
1answer
26 views
How to dynamically change the key names of object properties in an array
I have an array of objects, like so:
arr = [{"timeslot":"6am7am","AVG(Monday)":10,"AVG(Tuesday)":11,"AVG(Wednesday)":7}]
Each object will always contain the "timeslot" property, and can contain any ...
0
votes
3answers
38 views
React component DOM not updating
I have an array of objects. Each object represents a product and they are added and removed from this array and the DOM reflects this properly. Problem is when I update one of the properties of these ...
0
votes
1answer
42 views
Iterating through an objects values
Im working with OOP and looking at how to iterate through an objects values, as an example, this code:
var numbers = {
one: "number one",
two: "number two",
three: "number three",
...
-2
votes
2answers
40 views
javascript object of object from json with angular - data not returned correctly [duplicate]
I have code that I fetch data from json file
return $http.get(serviceBase + 'Airlines.json').then(function (results) {
findAirport([results.data]);
// will return later
}
...
0
votes
2answers
32 views
Is it safe in Javascript to assume the existence of “constructor” property on variables with values other than “null” or “undefined”?
I was wondering if it is safe to assume that in JavaScript a variable will always have a "constructor" property if its value is not "null" or "undefined".
I ran into a situation where I had to check ...
2
votes
2answers
34 views
How to iterate an array of objects and group the property values by their key name?
I have an array of objects named data, like so:
data = [{"timeslot":"7pm-8pm","Monday":60,"Tuesday":55},
{"timeslot":"8pm-9pm","Monday":70,"Tuesday":60},
{"timeslot":"9pm-10pm","...
-1
votes
0answers
47 views
I need to write a cycle, that will fill object in object
I have this code that makes array, but I need object in object:
var testInfoObj = {
"test_id": test_id,
"iblock_id": iblock_id
}
var answerObj = {
"question": question,
"question_id": ...
0
votes
1answer
36 views
HTML element attached to JS object
I just stater a bit of OOJS but I can't get my head around one thing, making an object for and HTML element and adding events to it.
For practice sake I had an idea to make inputs that can be ...
0
votes
0answers
30 views
Strange calling on object [closed]
When I was roaming the internet and learning JS, i found this code and I am a bit confused.
function escapeChars (testString) {
var map = {
'&': '&',
'<': '<',
...
0
votes
1answer
20 views
How to reference an array dynamically using the name of an object's property
I want to iterate an object's properties, and push the value of each property to an array sharing the property's name.
How can I reference the array name dynamically using the name of a property?
...
0
votes
2answers
12 views
Cannot read property 'decomposeTextShadow' of undefined [duplicate]
I have the following object:
var decomposer = {
decomposeColor: function(color) {
},
removeColor: function(code) {
},
decomposeTextShadow: function(code) {
...
2
votes
5answers
39 views
How do I apply methods from a constructor object to an arbitrary object [duplicate]
I have a constructor object that has various fields; For a simple example, say
function Person(id, name) {
this.id = id;
this.name = name;
etc.
this.someFunction = function(xxx) {...}
}
Now, ...
0
votes
1answer
42 views
how can i check whether which kind of function is they are and how can clear the clearIntervals if exists
1) How can i check which kind of javascript function is ?
In this below code.i have assign idlecheck to the setInterval function, normally we have check the function in javascript as below.
if (...
-5
votes
0answers
44 views
Want to write code to fetch data from nested javaScript object
var obj = [{
name: "Vi jay",
age: 20,
marks : {s1:50,s2:60,s3:30,s4:70,s5:80,s6:45,s7:34};
}, {
name: "ram",
age: 20,
marks : {s1:50,s2:60,s3:45,s4:70,s5:20,s6:45,s7:34};
},...
0
votes
1answer
37 views
How to pass a variable in replace function
I have been using the replace function since long to remove the classes from JavaScript, Now I was making the JavaScript function for that through which, I can pass an element and the class name to ...
0
votes
2answers
49 views
Why clearInterval not clearing the setInterval timer
i have creating an simple Timer service.In the timer service, i am monitoring the user for each minute.
while page load,have set 3 minutes to get an alert to logout and before 1 minute which means 2 ...
0
votes
2answers
33 views
Getting the sum of the values of the properties of an object
I'm looking to take the result of a survey that I created using JSON, add up the values associated with the objects from that survey in order to produce a sum. However, I am unsure of how to call upon ...
0
votes
0answers
21 views
Console says typeof variable is object, but is somehow undefined [duplicate]
I'm trying to take an object and extract some contents into a new variable, but I'm running into undefined variable issues. Below is my code:
<script src="https://apis.google.com/js/api.js"><...
-5
votes
0answers
33 views
How can I upload file with desire with path use value in type=“file” ???
I want to uploud file with on desire path using post method in form is that possible..
<form action="example.php" method="post" enctype="multipart/form-data">
I have a <input type="file" id=...
1
vote
1answer
50 views
Extraction of string using regex in javascript
I have a string of the following format:
"hello(%npm%)hi"
My goal is to split the string into three parts
a) hello
b) (%npm%)
c) hi
I am using regex as follows:
var myString = "hello(%npm%)hi"....
0
votes
2answers
45 views
Retrieve nested objects JavaScript
My object from Firebase when I console.log:
Object {AW: Object, Qdoba: Object}
Then under the restaurant titles of AW and Qdoba, I have title and address which I can expand on and see in my console. ...
0
votes
1answer
43 views
Can't iterate over my array/object. Javascript, React Native
I really don't understand what could be going on here. So I have a function which takes a 2d array and a string and iterates through the 2d array and checks if any subarrays contain the string. But ...
2
votes
1answer
39 views
JS: Javascript closure issue in prototype instance
As for a JS-newbie, I'm struggling with JS-closure. Googled enough, though can't understand why "this" is not available in "store" function. Any help will be appreciated:
;(function (win) {
var _af = ...
0
votes
1answer
40 views
typescript object property has data, parent object shows same property as empty
I'm seeing some strange behavior where an array which is the property of an object appears populated when logged to the console (and used in other places), but when the parent object is logged, it ...
0
votes
2answers
36 views
Looking for replace Object.entries() with ReactJS
I created such a code (and it works locally in Google Chrome but doesn't work on AWS) :
parameters: {
'forces': 100,
'hit': 5,
'defense': 5
}
<Parameters params={this....
1
vote
1answer
36 views
How to properly un-nest and flatten an array of javascript objects with an array inside them (X-amount of times)
I'm currently working with an array of javascript objects with X-amount of array's with the same type of object inside it, in a specific property (in this case, 'modelChildren')
I would like to ...
-3
votes
1answer
21 views
Change JQuery code to Vanila Javascript
I want this code in vanila javascript
and this is my code :
$("html, body").animate({ scrollTop: $(document).height() }, 1000);
thx
-1
votes
1answer
44 views
Typescript Convert Object to Array - because *ngFor does not supports iteration of object
I don't want to use for loop to convert Object to Array like this! If doubled the process and slow down the performance of app (I'm using Ionic2 and Typescript, with Firebase)
for(let key in data) {
...
-2
votes
4answers
71 views
How do you put the last character 1st in a string [closed]
The R is displaying last in the string initially it must display first how can I put the last character before the number value in the string so that it can display at the beginning of the value
...
0
votes
2answers
55 views
How do you iterate over a JavaScript object's properties like an array?
I don't mean using a for loop using the keys.
For example if you had an array like:
var fruitArray = ["Apples", "Bananas", "Coconuts"],
curFruit = 0;
You could "iterate" over that using ...
-1
votes
1answer
22 views
filter items from an array of javascript objects
I have a map of the form,
var map1 = {123 : true, 345: false, 456:true} ; where 123, 345, 456 are ids with status 'true' or 'false'.
Now, based on the boolean status of the ids above, I need to ...
-1
votes
1answer
29 views
creating new object from other
only first way of creating object in javascript is letting me create new object from it. second and third way of creating object are throwing error
can someone tell me why this is happening. and let ...
0
votes
0answers
16 views
Window.closed function works even before closing the window
I am opening a window from a page ( parent), using the openPopup() function. when the child window closes, I need some activity in the parent window. Some of the IE browsers, this is not functioning ...
-1
votes
1answer
53 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
19 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
48 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
63 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
30 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
38 views
How to create new object in javascript from variables? [closed]
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 = ...