web dev javascript polling q's

0.0(0)
studied byStudied by 1 person
full-widthCall with Kai
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/55

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

56 Terms

1
New cards

Javascript uses what type of typing, which determines variable type at runtime.

dynamic typing

2
New cards

Java script data types

string, array, bool, number

3
New cards
<p>what would you expect this code to output?</p>

what would you expect this code to output?

true, false

4
New cards
<p>what would you expect this to output?</p>

what would you expect this to output?

510

5
New cards

what does console.log(array) do?

outputs array like

0: firstElement

1: secondElement

2: thirdElement

6
New cards

array.length

returns array length

7
New cards

for(let name of names) in javascript

for(string name: names) in c++

8
New cards

define a function named printValues with two parameters names and ages

function printValues(names, ages){}

9
New cards

do you need to declare function before you call it?

no

10
New cards

overloading javascript sort funtion

you can define and call an entirely new function within the .sort parentheses

11
New cards

define arrow function named add that adds a and b

let add=(a, b)=>(a+b);

12
New cards

how to add new items to an array

.push(“newName”)→ adds to the end, or unshift(“newName”) → adds it to the beginning

13
New cards

what is the standard for javascript

ECMAScript

14
New cards
Java vs. JavaScript
They are unrelated languages.
15
New cards
Running JavaScript

Runs inside either script tags or in an outside file. you can also type directly in the console

16
New cards
Executed by interpreter
JavaScript is interpreted line-by-line.
17
New cards
Semicolons in JavaScript
Optional but often used to end statements.
18
New cards
Special Values
NaN, null, and undefined.
19
New cards
Variables: let vs. const
`let` for changeable, `const` for fixed values.
20
New cards
Comments

// or /* */

21
New cards
Operators: === vs. ==
`===` checks type and value; `==` checks only value.
22
New cards

how to concatenate strings

+

23
New cards
String and Number Rules

Numbers convert to strings when concatonated

24
New cards

for each/for of loop

for(let char of string)

25
New cards
Functions
Named, anonymous, and arrow functions.
26
New cards
Local vs Global Scope
Local variables belong to functions, global to the program.
27
New cards
Default Parameters

function myFunction(defaultNum = 1)

28
New cards
Arrays
Declared with `[]`; access by index.
29
New cards
Array Method: length
Finds the number of elements.
30
New cards
Array Method: push()
Adds elements to the end.
31
New cards
Array Method: pop()
Removes the last element.
32
New cards
Array Method: sort()
Arranges elements in order.
33
New cards
Iterating Arrays
Use `for`, `for-of` loops.
34
New cards
Built-in Function: console.log()
Outputs messages to the console.
35
New cards
Built-in Function: parseInt()
Converts strings to integers.
36
New cards
Built-in Function: parseFloat()
Converts strings to floating-point numbers.
37
New cards
Built-in Function: isNaN()
Checks if a value is NaN.
38
New cards
Built-in Function: prompt()
Asks user for input.
39
New cards

define an object named object with an element1 named “Hello”

let object = {

element1: “Hello”,

}

40
New cards
Adding Object Properties
Use dot or bracket notation to add.
41
New cards
Object Methods
Define actions for objects; `this` refers to the object.
42
New cards
Accessors
Getters and setters control property behaviors.
43
New cards
Debugging
Use Chrome DevTools for debugging.
44
New cards
String Method: charAt()
Gets a character at a position.
45
New cards
String Method: indexOf()
Finds the position of a substring.
46
New cards
String Property: length
Finds string length.
47
New cards
String Templates
Use `` `${expression}` `` for dynamic strings.
48
New cards
<p>what would this program output?</p>

what would this program output?

15, 3, 5, 9

49
New cards

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

50
New cards
<p>what would you write to output denver broncos?</p>

what would you write to output denver broncos?

game.homeTeam.name

51
New cards
<p>how to output Susan Cain?</p>

how to output Susan Cain?

book.authorFullName

52
New cards
<p>set birthYear to 1985</p>

set birthYear to 1985

book.author.birthYear = 1985;

53
New cards
<p>what is s assigned?</p>

what is s assigned?

a $a 5

54
New cards
<p>What is missing from the if statement to count the number of spaces in string s?</p>

What is missing from the if statement to count the number of spaces in string s?

s.charAt(i)=== “ “ or s[i] === ” “

55
New cards

how do you add a property to an object that already exists?

objectName[newProperty] = newProp;

56
New cards

what happens when you multiply a number by a string?

the string is converted to a number