ENG1003 Study Guide - Final Guide: Concatenation, Instance Variable, Nan

69 views3 pages
Bug =%error$or$glitch$in$a$software$program$(unintended)$-
can$be$either$yours$or$software's$fault
Arrays:$use$[$not$(
shoppinglist []
VS$object
Sarah.age
Manuals/look%up
-MDN$(Mozilla$
Dev$Network)
-W2Schools
Variables:$store$references$to$underlying$objects
Using$=== not$==
=== evaluates$both$value$and$data$type.
Var$result$=$1$==$true;
OUTPUT%IS%FALSE%even%though%true%is%taken%as%1%sometimes
Because%this%sign%===% in%JS%evaluates%both%value%and%data%type.
Since%1%is%number%and%true%is%a%string/boolean,%NOT%the%same.
So$use$===$NOT$==.$Makes$a$diff.
True%=$1
False =$0
Anything$between$quotation$marks won't$be$
interpreted
UNLESS$\ before " -->$for$string$
literals$that$need$to$contain$quotation$
mark$(start$and$end)
"<p$style=\"color:$"+$color$+$";
\">"$+$message$+$"</p>"
§
For$stuff$within$tags,$use$'$'
"<h1$id$=$'clock'>Time</h1>"
§
+= if$output$is$declared$beforehand,$to$
increment/replace$into$old$variable$output
eg. output += "";
=if$not$declared$beforehand
++ increment$by$1$each$time
eg.$ i++;
-- decrement$by$1$each$time
Basics:
Number$+$number$=$adds$together$mathematically
console.log();
->$means$output$of$console.log()$will$be$sent$to$the$Console$in$
Chrome
->$console$displays$relevant$info$to$developer$but$not$user
->$only$visible/useful$if$using$Develop$Tools$or$Playground
var outputAreaRef =
document.getElementById("outputArea")
outputAreaRef.innerHTML = output;
NaN =$special$number$represented$by$JS.
String%concatenation??
2%+%"3"%=%"23"
2$+$3$=$5
"2"$+$"3"$=$"23"
"1"%-"2"%=%%-1
1$+$true$=$2
"1"$+$true$=$"1true"
Math%ops
Math.round(distance)$-->$to$nearest$integer
distance.toFixed(2)$-->$to$2dp
Math.power(x2$-x1,$2)$-->$squares$difference$of$
x2$-x1
.length -->$$number$of$characters$and$spaces,$
not$words
Eg:$var text =$"The$cat$is$brown";
text.length is$16,$not$4.
Math.floor(text.length)$-->$to$next$lower$integer
Math.ceil(text.length)$-->$to$next$highest$integer
.valueAsNumber only$works$if$<input
type = "number"…>
i(index)$starts$from$0!
So$if$text.length =$7,$then$index$of$final$
character$will$be$[i -1],$not$i.
Mostly$used$as$a$counter$in$for$loops.
HTML%tags
"<br$/>"$-line$break
**
Attribute%VS%property
Attribute$=$private$instance$variable
Property$=$
Class%VS%object%VS%instance
Class$=$
Object$=$
Instance$=$an$object$that$has$the$
same$set$of$methods$and$properties$
(but$properties$have$diff$values)
JavaScript*General
Tuesday,$ 21$March$ 2017
21:41
Unlock document

This preview shows page 1 of the document.
Unlock all 3 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents