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...
And my other question what javascript resources or frameworks should I try to learn?
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>';
And my other question what javascript resources or frameworks should I try to learn?