click below
click below
Normal Size Small Size show me how
nshannon-JavaScript
Beginning JavaScript Vocabulary
| Term | Definition |
|---|---|
| Array literals | lists values in a pair of square brackets |
| Accessing array elements | You can get elements our of arrays if you know their index. The array's index starts at 0 and goes by increments of 1 |
| Multi-dimensional Arrays | an array within another array |
| Array constructor | creates an array using an array constructor |
| Accessing nested array elements | similar to one dimension arrays. accessed by using [index][index].the number you use depends on how deep you want to go inside |
| Boolean literals | syntax. True or false |
| Boolean logical operators | runs many true or false statements to get positive or negative feedback to what is true |
| Comparison operators | comparing two statements and seeing if they are equal, greater than, less than, or greater/less than or equal to |
| Note: | uses any non-zero #s to be true. any zero # is false, non-empty string is true and an empty string is false |
| == vs. === | == does just value checking and === does both value checking and type checking |
| Definition | defining code so you can understand later what you did |
| Single Line Comment | Anything on the line following // will be a comment while anything before will still be code. |
| Multi-Line Comment | Anything between /* and */ will be a comment. |
| console.log | prints text to the console which is useful for debugging |
| console.time | starts a timer which can track how long an operation takes to happen |
| console.timeEnd | stops the timer by calling console.time() |
| Function definition | a JavaScript procedure, many statements that perform a task or calculate a value. function is enclosed in {} |
| Function calling | calling a function like: greet("Anonymous"); |
| Function hoisting | Two ways of declaring function produce different results. By declaring a function you "hoist" it to the top of the call and makes it available before it is defined |
| If | simply states if that condition is true, do this, else do something else or nothing |
| Else | fallback to an if statement, only gets executed if the other statement did not |
| else if | It will only run if its condition is true, and the previous statement's condition was false |
| For Loops | used to repeat a certain code a specific amount of times |
| While Loops | Used when you don't know how many times you will execute a code. Only runs if it is true |
| Do While Loops | Used if you have to use a code at least once but you don't know how many times you will need to use it |
| random | returns a random number between 0 and 1 |
| floor | returns the largest integer less than or equal to a number |
| pow | returns base raised to exponent |
| ceil | returns the smallest integer greater than or equal to a number |
| PI | returns this value: 3.14159265 |
| sqrt | returns the square root of a number |
| % (Modulus) | returns remainder left after dividing the left hand side with the right hand side |
| isNaN | returns true if the given number is not a number else returns false |
| Basic Arithmetic | doing basic arithmetic is simple |
| Prefix and Postfix increment/decrement operators | Prefix increment: operators that first increase the value of the variable by 1 (increment) or decrease the value of an expression / variable by 1 (decrement) and then return this incremented / decremented value. Postfix increment: operators that first re |
| Object Literals | used as a means of encapsulating data, enclosing it in a tidy package to minimize the use of global variables which can cause problems when combining code |
| Property Access | name1[string] name2.identifier |
| Classes | A class can be thought of as a template to create many objects with similar qualities. Classes are a fundamental component of object-oriented programming (OOP). SubClass.prototype = new SuperClass(); |
| alert | alert(message); he alert dialog should be used for messages which do not require any response on the part of the user, other than the acknowledgement of the message. |
| confirm | confirm("message") //returns true if confirmed, false otherwise |
| prompt | The prompt() displays a dialog with an optional message prompting the user to input some text prompt(message); |
| Concatenation | string1 + string2 |
| length | string.length |
| toUpperCase, toLowerCase | Changes the cases of all the alphabetical letters in the string. |
| trim() | Removes whitespace from both ends of the stringstring.trim() |
| replace() | Returns a string with the first match substring replaced with a new substring. |
| charAt() | Returns the specified character from a string.string.charAt(index) |
| substring() | Returns the sequence of characters between two indices within a string. string.substring(indexA[, indexB]) |
| indexOf() | Returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex, Returns -1 if the value is not found |
| switch | Acts like a big if / else if / else chain. Checks a value against a list of cases, and executes the first case that is true |
| Ternary Operator | The ternary operator is usually used as a shortcut for the if statement |
| Variable Assignment | var name = value; |
| Variable changing | varname = newValue |