Flashcards
JSFlashcards
Cards in this deck (32)
- 1whats the diff between let and varlet is scoped to the code block
var is scoped to the function block
use let - 24 rules for variable names`cant be reserved
should be meaning
cant start with number
cant have space or - - 3variable typesprimitives and referenct types
- 4primitive typesstring
numbers
boolean
undefined
null - 5undefined typeall vars set by default
- 6dynamic typingthe types can change with use
- 7what is special about undefinedits a type and a value
- 8reference typesobject
array
function - 9example of object literallet person = {}
- 10make a person objectlet person = {
name: 'test',
age: 44
}; - 11accessing an objects props 2 types and exameplsdot notation and bracket notation
person.name
person['name'] - 12why use bracket notiationwhen you dont know the name of the property at dev, but only at runtime
- 13example of an array literallet selectedColors = [];
- 14what does === meanstrict equality
compare type and value - 15what does == mean, and how does it do it?loose quality, just compare values, not types so
1 is the same as '1'
it takes the type on left, converts the type on right and then does === - 16example of ternarylet type = pts > 100 ? 'true result' : 'false result'
- 17logical operator and non boolthis is when you try to compare diff types of values
- 18Falsy valuesfalse
0
'' or ""
null
undefined
NaN - 19example of switchlet role;
switch (role) {
case "test": {
console.log("sd");
break;
}
default: {
console.log("sdss");
}
} - 20for in loopthis is to view the props of an object
for (let key in someobject)
{
console.log(key);
} - 21diff between : and =: is for Literal Notiation, for key value pairs
{
name : 'test'
}
this is a shortcut just for object literal notations
= is for Assignment
name = 'test' - 22what is hoistingwhen js runs, it takes all the f declarations and moves them to the top.
thats why you can run a declared function before its defined. - 23what is 'this'its the object thats executing the current function
- 244 pillars of OOPencapsulation
abstraction
inheritance
polymorphism - 25encapsulationincrease usablity
group related data and funcs into a unit and then ref that unit when needed
this is an object with Properties and methods - 26simple diff between oop and proceduralprocedural has funcs with lots of params, its how the data gets in
Opp creates objects with minimal or no params, so that you just have to call the func, and it has access to the props in the object - 27abstractionsimplify the interface to O, hide complexity
reduces the impact of change because the use is simple - 28inheritanceby creating base O, you can create objects based on that baseO that dont have to have all the dup methods and props.
- 29polymorphismmany forms
a bunch of objects, might have the same func render(), but each of them will do it differently. but all will have a render() - 30what is closureits the scoping of properties to inside methods,
- 31How do you do oop with classic JS? when there are no classesprototypes
a proto is a parent object - 32how does JS engine search for a method or propstarts with the current obj, and if it cant find it, it will crawl up the proto chain until it finds it
Information
- Description
- MCAT Computer Studies Flashcards on JSFlashcards, created by test test on 04/01/2019.
- Created by
- test test
- Views
- 1,358
- Rating