Linked Questions

31 votes
2 answers
15k views

In javascript given this three constructor functions: function Foo(data) { var _data = data; } function Bar(data) { this.data = data; } function Baz(data) { //just use data freely. } ...
Pablo Fernandez's user avatar
17 votes
6 answers
1k views

Possible Duplicate: Javascript: Do I need to put this.var for every variable in an object? I'm struggling to understand functions and objects in javascript. It is said that also functions are ...
Parzival's user avatar
  • 312
3 votes
3 answers
8k views

I have a really simple JavaScript question... I have a function, Pets, that contains three variables: an integer, a string, and an array defined as follows: function Pets() { var index; var ...
Jan Tacci's user avatar
  • 3,221
4 votes
3 answers
6k views

I am new to javascript. I was doing some hands on "object literals". Below is the code i was trying. BodyLoaded is the event handler for onload event of body tag. //works - getName returns "bingo" ...
Rohit Raisinghani's user avatar
2 votes
1 answer
3k views

I have two javascript objects that are used to replicate data objects. They are filled in via onclick events, and I want to clear them out after a save event. For example, var currentStrategy = { ...
Jason's user avatar
  • 11.4k
4 votes
1 answer
2k views

I've found similar questions, but none that answer this explicitly, so I hope someone can help clear this up for me. In regards to constructor functions, I am trying to figure if variables and ...
Jose's user avatar
  • 5,270
0 votes
3 answers
4k views

So I have a question about this and just having normal variables in classes. Normally we do something like this: class Thingy { constructor(thing) { this.id = thing } printID() { ...
msmith1114's user avatar
  • 3,307
4 votes
2 answers
1k views

i have a simple Javascript "class" im testing right now. I noticed that "this" in my private functions do not point to the object itself, instead, its pointing to the global scope (window). Why? ...
NovumCoder's user avatar
  • 4,727
3 votes
2 answers
193 views

Trying to create a class in JS with the attribute weight in the following code: function Foo() { var weight = 10; console.log(weight); } When I instantiate it with var bar = new Foo();, 10 is ...
Einar Sundgren's user avatar
1 vote
1 answer
2k views

I'm beginner in em ES6, and I need instantiate new objects inside a class. How the best way to make this, and how I can access "in this case" the connection in the function getName(). Probably ...
Henrique Van Klaveren's user avatar
0 votes
2 answers
880 views

After using push() method, I print the item arr[i].title into console and it shows 'undefined', instead of "God father 1". See line 12 of the code. Here is the code: <!doctype html> <html ...
Hesham's user avatar
  • 625
2 votes
2 answers
905 views

Why isn't this code working? I'm trying to use the method to add up the properties and then assign the added up properties to its own value. function howLongILivedSomewhere(college, home1, home2) { ...
Orbers's user avatar
  • 79
0 votes
2 answers
411 views

I read a few articles and questions heres but I still don't understand how to achieve this. The following snippet will help me to explain what I am trying to do: function Employee(id, name, email){ ...
BeingSuman's user avatar
  • 3,353
0 votes
3 answers
304 views

I have this snippet of code. I am very new to JavaScript, and I have an error in: class X { constructor() { this.pick = -1; this.isClosed = false; this.pline = []; } add(...
Amin's user avatar
  • 327
0 votes
1 answer
591 views

I am slightly new to react and ES6 in general and am trying to create a resuable app drawer component connected to a navbar. I am trying to use the classnames npm package to conditionally render the ...
koalamo's user avatar
  • 199

15 30 50 per page
1
2 3 4 5
10