Lecture 2 Intro To JS
Lecture 2 Intro To JS
… by koen peters
History & Version of JS
At the begging of the script we can use the literal “use strict” to restrict
global declaration.
JS Data Types
The two examples above do exactly the same. For simplicity, readability
and execution speed, use the first one (the array literal method).
JS Array & It’s methods
Like the above toString() methods we have many more array manipulation
methods in JS. Some of them are following:
We have a special property for called “length” that gives the number of
element of an array.
JS Functions
Like other programming languages JavaScript also has the following loops:
Example-1:
var student = new Object();
student.name = “XYZ”;
student.age = 20;
student.getName = function (){ return this.name}
Example-2:
function student(name, age) {
this.name = name;
this.age = age;
}
var s1 = new student(“ABC", 20);
Example-3:
var s1 = { name: “XYZ", age: 50 };
Object Property & Method Access
var student = {
name: ‘xyz’,
age: 20,
getName() = function(){ return this.name}
}
1. https://www.w3schools.com/js/default.asp
2. https://www.tutorialspoint.com/javascript/index.htm
3. https://stackoverflow.com/questions/20435653/what-is-vanillajs
4. http://www.cs.ucc.ie/~gavin/javascript/
5. https://www.w3schools.com/js/default.asp
Thank You!