Bitmaker Labs – Day 24

Day two of Javascript has been more or less been the same as yesterday. We continued talking about methods and variables, followed by simple functions and constructs. Constructs are a new concept, and it took me a fair bit to fully grasp their purpose, and now that I do, I appreciate how useful they can be. A constructor basically builds a new object for you, without you having to explicitly type everything out over and over.

function Student(name, age){
	this.name = name;
	this.age = age;
	this.school = "Bitmaker";
}

//Here I'm making a new Student object with salman as the variable.
var salman = new Student("Salman", 17)

//by calling salman, now you see what the constructor has done for me: It's created an object with attributes.
salman // => Student {name: "Salman", age: 17, school: "Bitmaker"}

This is pretty neat.Tomorrow we learn about DOM manipulation, which is the fun part of JS.