1/33
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Commets in JavaScript Coding. Role + different types + Shortcut
it is used for notes or explanations so that humans can read code. The computer ignores it when code runs.
2 different types:
//
/* */
Shortcut: To comment or uncomment use command key and slash.
What are the data types and what they do?
Undefined- something that has not been define ex. you have not set variable to set anything.
Null- set it to be something and that thing is nothing.
Boolean- true or false
string- to represent text, used by single, double quotes, or backticks.
symbol- an immutable primitive value that is unique.
number- number
object- can store a lot of different key value pairs
Set data into a variable
What is variable? and how to declare a variable.
containers for storing information (value).
to declare or create variable. ex. declare a variable and set it to something
what are the different ways to declare variables? what are the difference?
Var- be able to used throughout your whole program.
Let- it is limited of where you declared that.
Cons- a variable that never changes.
How do you know if variables are initialized vs. uninitialize?
initialized variables are set to something or an assignment while uninitiliazed does not.
difference between declaration and assignment?
declaration is creating the variable while assignment is giving value.
why is case sensitivity important?
because it will run in the console as undefined, so it is important that that case are exactly the way it is.
what are the two different ways of incrementing(decrementing) numbers? and what are the easier way?
ex. myVar = myVar + 1;
instead,
myVar++;
how to use a remainder? why is it useful?
%
ex.
9 % 2
to determine if the number is even or odd.
with compound number, how do you augment addition?
with the assigned value, instead of 12 + a, use += that included to adding a number you like. shortcut. same thing with like subtraction, division, multiplication.
why is backlash important when double quoting?
backlash\ before each quotation mark helps to recognize the one you want to see quoted inside a quotation. It makes it a full string.
what are the different escape sequence?
\’ single quote
\” double quote
\\backslash
\n newline
\r carriage return
\t tab
\b backspace
\f form feed
what is bracket notation?
a way to get a character at a specific index within a string. instead of counting to one. Computers count start from zero
what is .length represent?
it represents how many characters are inside the string
string immutability
they cannot be altered once created. individual character cannot be change it has to be as a whole.
instead of string [0] = “A” . it is string = “Arts”
the difference between bracket notation to finding the Nth character and the Nth to the last character
finding the character is simply [], but the last character is firstName[firstName.length - 1]. It is always.
In bracket notation in finding last character, how can we do if it was the third to last character?
it is the same thing. thirdToLastCharacter = firstName[firstName.length - 3];
How to use word blanks? and how is it formatted?
it is like Mad Lib, provided with sentences with some missing words like nouns, verbs, adjectives, and adverbs.
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = ““ ——> start with empty array
result += …
return result; ——> to end it
}
difference between array and string
this is array [], this is string ““
what is an array?
always start with a black and end with a bracket to show the beginning and ending of an array, every element of an array is always separated by a comma. Elements can be any data type
difference between regular arrays and nested arrays
[]——> regular arrays
[[‘string’],[numbers]]——→ nested arrays
how do you access array using indexes
the way we can find a string, is the same way we can with the array.
difference between index array and modify array data
the same as string, you can do with array. modify array you can change the specific character you want.
multi-dimensional array
there are more numbers inside the array and more brackets, to access the array, you would use double bracket array.
difference between push and pop array
push is adding something:
pop removes the final element
array shift
it gonna remove the first element
unshift function
similar to push array. but it will replace the first element instead.
how to use reusable function?
put console.log inside bracket then outside bracket, reusableFunction()
what is function in javascript
like a mini machine that does something when you give information.
what is the type of information when the mini machine function something like information is given
that information is called an argument.
what happens after when the function like a mini machine that does something when you give it information, that information is called an argument?
parameters come in. the machine (function) accepts that info through something which is called parameter.
global scope
a variable that has global scope, if you create it outside of any function, block, or curly braces. that means it can be used anywhere in your program.
ex. when you write something in classroom whiteboard, anyone in room can see it - that’s global scope.
local scope
a variable has local scope when it’s declared inside a function (or a block like {}), which means it only exists there. It cannot be use outside that function or block —it’s “locked in”.
ex. you write something in your notebook during class, only you can see it. called local scope.
undefined value return means
variable exist but does not have value yet.