Thursday, 22 August 2013

How to make inner function to return inner variable in javascript

How to make inner function to return inner variable in javascript

Forgive me for asking this simple question.
I want to get the inner variable through method.In java, I can achieve it
as below code.
class MyClass{
String words = "hello";
MyClass(){
// constructor
}
String getWords(){
return this.words;
}
}
Then, I can get the words (inner variable) by calling the method getWords().
MyClass myClass = new MyClass(); // object instance
System.out.println(myClass.getWords()); // get the words
My question is, how can i achieve such thing in javascript.

No comments:

Post a Comment