Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
Quick question about javascript
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="GarettM" data-source="post: 439687" data-attributes="member: 839"><p>I have been playing around with javascript for about a week now and I am starting to feel a little comfortable with it, still kinda weird but its not that bad, The hardest part I have been dealing with is classes in JavaScript, is there a proffered way on declaring classes? This is how I have been doing it so far...</p><p></p><p>[CODE]</p><p></p><p>/**</p><p> * @constructor</p><p> * @name Person</p><p> */</p><p>var Person = function Person(name, age) {</p><p> this.name = name;</p><p> this.age = age || 0;</p><p>};</p><p>/**</p><p> * @function</p><p> * @name Person#getName</p><p> */</p><p>Person.prototype.getName = function () {</p><p> return this.name;</p><p>};</p><p>/**</p><p> * @function</p><p> * @name Person#setName</p><p> */</p><p>Person.prototype.setName = function (name) {</p><p> this.name = name;</p><p>};</p><p>/**</p><p> * @function</p><p> * @name Person#getAge</p><p> */</p><p>Person.prototype.getAge = function () {</p><p> return this.age;</p><p>};</p><p>/**</p><p> * @function</p><p> * @name Person#setAge</p><p> */</p><p>Person.prototype.setAge = function (age) {</p><p> this.age = age;</p><p>};</p><p>/**</p><p> * Declaring a new Person as Ted with the name of "Ted" and age of "15"</p><p> */</p><p>var Ted = new Person("Ted", 15);</p><p>//</p><p>var logmsg = "Created a new Object [ted] = Person(" + Ted.getName() + ", " + Ted.getAge() + ")";</p><p>// log to console</p><p>console.log(logmsg);</p><p>// log to html tag</p><p>var consolediv = document.getElementById('console');</p><p>consolediv.innerHTML = '<p>' + logmsg + '</p>';</p><p>[/CODE]</p><p></p><p>And my other question what javascript resources or frameworks should I try to learn?</p></blockquote><p></p>
[QUOTE="GarettM, post: 439687, member: 839"] I have been playing around with javascript for about a week now and I am starting to feel a little comfortable with it, still kinda weird but its not that bad, The hardest part I have been dealing with is classes in JavaScript, is there a proffered way on declaring classes? This is how I have been doing it so far... [CODE] /** * @constructor * @name Person */ var Person = function Person(name, age) { this.name = name; this.age = age || 0; }; /** * @function * @name Person#getName */ Person.prototype.getName = function () { return this.name; }; /** * @function * @name Person#setName */ Person.prototype.setName = function (name) { this.name = name; }; /** * @function * @name Person#getAge */ Person.prototype.getAge = function () { return this.age; }; /** * @function * @name Person#setAge */ Person.prototype.setAge = function (age) { this.age = age; }; /** * Declaring a new Person as Ted with the name of "Ted" and age of "15" */ var Ted = new Person("Ted", 15); // var logmsg = "Created a new Object [ted] = Person(" + Ted.getName() + ", " + Ted.getAge() + ")"; // log to console console.log(logmsg); // log to html tag var consolediv = document.getElementById('console'); consolediv.innerHTML = '<p>' + logmsg + '</p>'; [/CODE] And my other question what javascript resources or frameworks should I try to learn? [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
Quick question about javascript
Top