Be able to write out these skeletons in less than five seconds. It is vital that these are committed to memory and you don't need to think about it when asked to create these.
- Defining a function
var aFunc = function(arg1, arg2) {
// your code in function body here using arg1 and arg2
}
- Iterating over an array
for (var i = 0; i < array.length; i++) {
// your code in loop body here using array[i]
}
- Looping from 0-10
for (var i = 0; i < 10; i++) {
// your code here using i
}
- Looping over an object
for (key in object) {
// your code here using key
}
- If statement
if(truthyStatement) {
// do something here
} else if (someOtherTruthyStatement) {
// otherwise do stuff in this block
} else {
// otherwise default to do stuff in this block
}
- Array access
var myArray = [];
myArray.push('hello');
myArray.push(10);
console.log(myArray[0]);
console.log(myArray[1]);
- Object access
var myObject = {};
myObject['name'] = 'MyName';
console.log(myObject.name);
var myVar = 'age'
myObject[myVar] = 100;
console.log(myObject.age);
Methods to know about. You should be able to know what each of these does and quickly navigate documents to get the exact syntax.
- Strings
- charAt()
- concat()
- contains()
- indexOf()
- length()
- search()
- splice()
- split()
- sub()
- substr()
- toLowerCase()
- toUpperCase()
- Arrays
- join()
- length()
- pop()
- push()
- reverse()
- shift()
- unshift()
- slice()
- splice()
- Objects
- Object.keys()
Be able to write out these skeletons in less than five seconds. It is vital that these are committed to memory and you don't need to think about it when asked to create these.
Methods to know about. You should be able to know what each of these does and quickly navigate documents to get the exact syntax.