1/55
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Javascript uses what type of typing, which determines variable type at runtime.
dynamic typing
Java script data types
string, array, bool, number
what would you expect this code to output?
true, false
what would you expect this to output?
510
what does console.log(array) do?
outputs array like
0: firstElement
1: secondElement
2: thirdElement
array.length
returns array length
for(let name of names) in javascript
for(string name: names) in c++
define a function named printValues with two parameters names and ages
function printValues(names, ages){}
do you need to declare function before you call it?
no
overloading javascript sort funtion
you can define and call an entirely new function within the .sort parentheses
define arrow function named add that adds a and b
let add=(a, b)=>(a+b);
how to add new items to an array
.push(“newName”)→ adds to the end, or unshift(“newName”) → adds it to the beginning
what is the standard for javascript
ECMAScript
Runs inside either script tags or in an outside file. you can also type directly in the console
// or /* */
how to concatenate strings
+
Numbers convert to strings when concatonated
for each/for of loop
for(let char of string)
function myFunction(defaultNum = 1)
define an object named object with an element1 named “Hello”
let object = {
element1: “Hello”,
}
what would this program output?
15, 3, 5, 9
how do you make an array nums be sorted in numerical order (as opposed to ascii order?)
nums.sort((a,b)=>a-b)— overloading the sorting function to sort in ascending order
what would you write to output denver broncos?
game.homeTeam.name
how to output Susan Cain?
book.authorFullName
set birthYear to 1985
book.author.birthYear = 1985;
what is s assigned?
a $a 5
What is missing from the if statement to count the number of spaces in string s?
s.charAt(i)=== “ “ or s[i] === ” “
how do you add a property to an object that already exists?
objectName[newProperty] = newProp;
what happens when you multiply a number by a string?
the string is converted to a number