All Questions
22
questions
0
votes
0
answers
110
views
How to get window object output in console using 'this' keyword in standalone function call
I want to check how 'this' keyword is behaving in Javascript ES6. To perform this I wrote code snippets to check output of 'this' keyword in object and also normal standalone function.
When I call the ...
1
vote
1
answer
1k
views
ES6 typescript class create object of itself inside
I have created a class and inside that class i want to create an array that consist of object of itself. In normal javascript if achieve it as follow
class Person{
constructor(name){
...
-2
votes
1
answer
348
views
Class returns empty property JavaScript [duplicate]
I have a simple class:
class Build {
dataFetched = {};
constructor(id = '') {
this.id = id;
}
getData(){
return request({
some request
}).then(({...
0
votes
0
answers
41
views
Given that Classes have been introduced, why would someone still use `let xyz = new Object()` today?
Plenty of articles on the internet still teach how to create objects in the following manner.
let car = new Object();
car.make = 'Ford';
car.model = 'Mustang';
car.year = 1969;
However, with the ...
2
votes
2
answers
34
views
Can one property value be passed as a argument to another property whose value is computed via a function ? (in Javascript ES6 with classes)
class A {
constructor(inval){
this.c = inval;
}
b() {
return this.c + 1;
}
e(z) {
return z+ Math.floor(Math.random()*10);
}
d() {
let x = {
x1: this.b(),
x2: ...
0
votes
2
answers
34
views
Perform initial task with parameters before executing function in JS
I'm making a tool. This tool should be able to accept parameter, perform an initial task to the parameters, then return a result depending on which function is invoked.
My first attempt was using an ...
0
votes
0
answers
29
views
javascript es6 classes: calling a method of a class inside another method of the same class [duplicate]
my code is:
PRELOADER_COUNTER = 0;
class Preloader {
constructor(timeout=15000) {
PRELOADER_COUNTER++;
this.counter = PRELOADER_COUNTER;
this.timeout = timeout;
}
...
0
votes
1
answer
21
views
Understanding the Properties of a Class
Why can't i just write gpa instead of this.gpa in my method? I set this.gpa = gpa in my constructor.
class Student {
constructor(gpa) {
this.gpa = gpa;
}
stringGPA() {
...
-2
votes
1
answer
47
views
How function can inherit a class attributes and methods in Javascript
In javascript I have a class and a function and I want the function to inherit the class attributes and methods.
As far as I know, when a function inherits another function we can use call() or apply(...
0
votes
2
answers
49
views
How can I use the value of a previous object property inside another property of the same object when I am declaring it
I have a class which returns an object with its properties. I would like to access to the value of a previous prop inside the constructor.
I have next working code:
class KafkaConsumer {
...
3
votes
3
answers
73
views
A few things I don't understand about inheritance
I have created such a table on "inheritance".
compare ---prototype---> Animal.prototype(constructor,run)
Rabbit ---[[prototype]]---> compare
Rabbit ---prototype---> Animal
Rabbit....
0
votes
2
answers
62
views
Is there a way for a set of class methods to know when call is terminated?
Libraries like lodash implement a .chain() method in which each subsequent chained method will return a reference to this allowing for the chaining to be possible. The downside of which is that at the ...
0
votes
1
answer
59
views
Declare object type in class
I should create a js class respecting a json format
{
"rows": [{
"value": {
"comments": ${dInfo.description},
"Tags": [],
"metadataList": {
"names": [],
...
1
vote
1
answer
83
views
Using an object as a method's argument in es 6
I am trying to take a new Point object as the argument of the plus method and then add to return the value. Point p will be correct in java but not in javascript.
class Point {
constructor(x, y) {...
3
votes
1
answer
9k
views
How to create an object inside class static method
I'm starting to learn more about static methods in classes, and was wondering if the following is doable:
Have a class that instantiate monsters (class Monster {...})
Allow someone to create a ...