Questions tagged [es6-class]

This tag is for questions regarding Classes in Ecmascript 6. The tag is only for classes provided in the Ecmascript version.

Resources

1259 questions
-1
votes
1 answer

the second slide doesn't work

I have a problem with slider,meaningfully pictures change only one time. I know only the next button wokrs , but it's fine,i think the each function is needed. My code: class Karuzela { constructor() { this.next = $('.next'); …
Pio
  • 123
  • 8
-1
votes
1 answer

How to handle methods that take arguments in es6?

Well, I am kinda surprised that I had to ask a question about this but most examples provide a getter and setter but I have not seems a functions that takes parameters in es6 classes. Given the following example from MDN web docs. class Rectangle…
Beto
  • 806
  • 3
  • 12
  • 33
-1
votes
1 answer

Why JavaScript objects doesn't gets copy of data and methods in ES6

One common aspect of object-oriented design (in most of the languages, especially Java) is that when we construct new object using constructor, all the methods and public/protected instance variables gets copied into the object. For example: Car…
-1
votes
1 answer

ES6 class add object of functions

I'm trying to include an object of function as a static class properties, to call like myClass.setPayload[id].call(this, buffer). Actually, i have this : var setPayload = { 0x01: function(buffer){...}, 0x0a: function (buffer) {...} } class…
Nicolas Frbezar
  • 497
  • 1
  • 5
  • 24
-1
votes
2 answers

Member function undefined - javascript

I have made this class: import React, {Component} from 'react'; import { View, ActivityIndicator, Button } from 'react-native'; import Auth from '../api/Auth'; export default class LoginScreen extends React.Component { …
Mohammad Areeb Siddiqui
  • 9,795
  • 14
  • 71
  • 113
-1
votes
1 answer

How do I get a variable out of a class in ES6?

Hi I don't get the variable out of the KeyCodeClass. Here is what I tryed: TEST 1 class KeyCodeClass1 { constructor() { this.space; } KeyDown(e) { if (e.keyCode == 32) { this.space = true } } KeyUp(e) { if…
TessavWalstijn
  • 1,698
  • 1
  • 19
  • 36
-1
votes
2 answers

performance of prototype vs passing object property

I have a class that needs a reference to a property from it's parent. I would like to know if it is better to pass in the property to the constructor of the child class and set it as a new property of the child class, or while in the parent class…
trickpatty
  • 433
  • 7
  • 18
-1
votes
1 answer

How to write public fields in pure ES6 class

Is possible to have public field in an ES6 class like this: class Device { public id=null; public name=null; constructor(id,name,token) { this.id = id; // I want this field to be public this.name = id; // I…
Kamil Kiełczewski
  • 85,173
  • 29
  • 368
  • 345
-1
votes
1 answer

Javascript ES6 - get name of instance from within class

I'd like to be able to get the name of the instance that instantiated a class, from within the class. Example: class MyClass { getInstanceName() { // code that figures out the name given to the instance // instantiating this…
froinds
  • 225
  • 4
  • 14
-1
votes
1 answer

React subclassing pattern with super()

In the active links section of the react router tutorial, they suggest the following for using active links. Most links in your site don't need to know they are active, usually just primary navigation links need to know. It's useful to wrap those…
ericmarkmartin
  • 717
  • 1
  • 8
  • 19
-1
votes
1 answer

where to format and map this array in the child component in ES6?

So I am getting a prop from a parent component. let's say that attribute has a data structure like the following: [{a: "a", b:"b"}, {c:"c", d:"d"}...] And this is the component that gets this prop. class Child extends Component { …
slopeofhope
  • 686
  • 2
  • 6
  • 21
-2
votes
2 answers

Call class method within try catch block?

I have encountered with something like this: class Example { // ... async #privateMethod() { return true } static staticMethod() { try { // can't access #privateMethod this.#privateMethod() } catch (error) { …
frostack
  • 1
  • 1
-2
votes
1 answer

How to create getter function with for loop in this class?

Using Typsescript here. I was able to set up a getter function to return all the values in the kids array but can anyone tell me how to create a getKid function in the class that allows me to put in the index and return the name of the kid…
Blockpain
  • 17
  • 3
-2
votes
1 answer

What happens if you send an instance of an ES6 class via REST API?

class Data { #some_private_var constructor(private_val, regular_val) { this.regular_var = regular_val this.#some_private_var = private_val } } For example, if I use Axios to make an API request with an instance of the above class as…
-2
votes
1 answer

Compare two arrays and return array of objects having property values which equals to another array of keys

var columnNames = [{columnName: 'User', id:'userName' }, {columnName: 'Email Id', id:'emailId' }] var tableData = [{userName: 'aaa', emailId: 'aaa@test.com', age: 20, middleName: 'test' }, {userName: 'bbb', emailId: 'bbb@test.com', age: 30,…
Soumya Behera
  • 2,325
  • 4
  • 15
  • 25
1 2 3
83
84