Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call method inside other class with EcmaScript 6 in Node JS #111

Closed
ngnlx opened this issue Sep 8, 2016 · 2 comments
Closed

Call method inside other class with EcmaScript 6 in Node JS #111

ngnlx opened this issue Sep 8, 2016 · 2 comments

Comments

@ngnlx
Copy link

ngnlx commented Sep 8, 2016

I have Javascript link this.

someClass.js

class someClass {
    constructor(name, age) {
        this.name = name;
        this.age = age;
    }

    sayName() {
        console.log(this.name);
    }

    sayAge() {
        console.log(this.age);
    }
}

var myInstance = new someClass('dwayne', 27);
myInstance.sayName();

In cmd:

node someClass.js
It's show dwayne.

But show I want to use this class in another class like: someClassTest.js How can I call someClass.js for same result

Thanks.

@getify
Copy link
Contributor

getify commented Sep 8, 2016

This is not a general support forum. Try Stack Overflow perhaps.

@luissantanderpro
Copy link

class someClass{

constructor(name, age){
this.name = name;
this.age = age;
}

getName(){
return this.name;
}

getAge(){
return this.age;
}
}

var myInstance = new someClass("John", 27);

// var doc = document.getElementById("test");
// doc.innerHTML = "Name: " + myInstance.getName() + "
Age:" +
myInstance.getAge();

class someClassTest{

constructor(name){
this.name = name;
}

getName(){
console.log("New instanced passed: " + this.name);
console.log(myInstance.getName());
}
}

var newInstance = new someClassTest(myInstance.getName());

newInstance.getName();

On Thu, Sep 8, 2016 at 8:51 AM, Kyle Simpson notifications@github.com
wrote:

This is not a general support forum. Try Stack Overflow perhaps.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#111 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ATlJsiI91oNaVtEA9Vv92e2fYGKS_e8_ks5qoC8OgaJpZM4J4ASI
.

@ngnlx ngnlx closed this as completed Sep 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants