click below
click below
Normal Size Small Size show me how
Javascript Vocab
Just the basic concepts and definitions for basic Javascript
| Term | Definition |
|---|---|
| Console.log() | The ______ method is used to log or print messages to the console. console.log('Hi there!'); // Prints: Hi there! |
| Javascript | ________ is a programming language that powers the dynamic behavior on most websites. Alongside HTML and CSS, it is a core technology that makes the web run. |
| Method | ________ return information about an object, and are called by appending an instance with a period " . " the method name, and parentheses. // Returns a number between 0 and 1 Math.random(); |
| Libraries | _______ contain methods that can be called by appending the library name with a period ., the method name, and a set of parentheses. Math.random(); |
| Numbers | _______ are a primitive data type. They include the set of all integers and floating point numbers. let amount = 6; let price = 4.99; |
| The 5 primitive data types | Numbers, Strings, Boolean, Null and Undefined |
| string.length | The .length property of a string returns the number of characters that make up the string. |
| Boolean | ______ are a primitive data type. They can be either true or false. |
| Math.random() | The _______ function returns a floating-point, random number in the range from 0 (inclusive) up to but not including 1. console.log(Math.random()); // Prints: 0 - 0.9 |
| Math.floor() | This function returns the largest integer less than or equal to the given number. console.log(Math.floor(5.95)); // Prints: 5 |
| Single Line Comment | ______ comments are created with two consecutive forward slashes //. // This line will denote a comment |
| Null | is a primitive data type. It represents the intentional absence of value. let x = null; |
| Strings | _____ are a primitive data type. They are any grouping of characters (letters, spaces, numbers, or symbols) surrounded by single quotes ' or double quotes ". let single = 'Wheres my bandit hat?'; let double = "Wheres my bandit hat?"; |
| Arithmetic Operators | + addition - subtraction * multiplication / division % modulo ** exponents ++ increment -- decrement |
| Multi-Line Comments | These comments are created by surrounding the lines with /* at the beginning and */ at the end. Comments are good ways for a variety of reasons like explaining a code block or indicating some hints, etc. /* The below must be changed. */ |
| Assignment Operators | This assigns a value to its left operand based on the value of its right. += add, -= subtract, *= multi, /= division let number = 100; // Both statements will add 10 number = number + 10; number += 10; console.log(number); // Prints: 120 |
| Variables pt.1 | ______ are used whenever there’s a need to store a piece of data. A variable contains data that can be used in the program elsewhere. Using variables also ensures code re-usability since it can be used to replace the same value in multiple places. |
| Variables pt. 2 | ______ are used whenever there’s a need to store a piece of data. const currency = '$'; let userIncome = 85000; console.log(currency + userIncome + ' is more than the average income.'); // Prints: $85000 is more than the average income. |
| Undefined | _______ is a primitive JavaScript value that represents lack of defined value. Variables that are declared but not initialized to a value will have the value______. var a; console.log(a); // Prints: undefined |
| Declaring a Variable | Any of these three keywords can be used along with a variable name: var is used in pre-ES6 versions of JavaScript. let is the preferred way to _______ when it can be reassigned. const is the preferred way to _______ with a constant value. |
| Var | ____ declarations, wherever they occur, are processed before any code is executed. This is called hoisting. The scope of a variable declared is global. |
| Let | _____creates a local variable in JavaScript & can be re-assigned. ______ allows you to declare variables that are limited to the scope of a block statement, or expression on which it is used, unlike the var keyword. |
| Const | ______ are block-scoped, much like variables defined using the let keyword. The value of a constant can't be changed through reassignment, and it can't be redeclared. |
| Function | Declares a function with the specified parameters. |
| Return | Specifies the value to be returned by a function. |
| Class | Declares a class. |
| For Loop | Creates a loop that consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop. let str = ''; _____ (let i = 0; i < 9; i++) { str = str + i; } |
| While Loop | Creates a loop that executes a specified statement as long as the test condition evaluates to true. The condition is evaluated before executing the statement. let n = 0; _______ (n < 3) { n++; } console.log(n); // expected output: 3 |
| If Else | If condition is truthy = executes. If falsy, another state can be executed. function testNum(a) { let result; if (a > 0) { result = 'positive'; } else { result = 'NOT positive'; } return result; } console.log(testNum(-5)); |
| Object | This class represents one of JavaScript's data types. It is used to store various keyed collections and more complex entities. |
| Equality Operators | == != === !== |
| Relational Operators | in instanceof < > <= >= |
| Binary Logical Operators | && - and || - or ! - not |
| Function Expression | The function keyword can be used to define a function inside an expression. const getRectArea = function(width, height) { return width * height; }; console.log(getRectArea(3, 4)); // expected output: 12 |
| Function Declaration | This (function statement) defines a function with the specified parameters. function calcRectArea(width, height) { return width * height; } console.log(calcRectArea(5, 6)); // expected output: 30 |
| NaN | The global ______ property is a value representing Not-A-Number. |
| String Concatenation | Multiple strings can be put together using the + operator. let service = 'credit card'; let month = 'May 30th'; let displayText = 'Your ' + service + ' bill is due on ' + month + '.'; |
| Arrays | Lists of ordered, stored data. They can hold items that are of any data type. ______ are created by using square brackets and commas. // An array containing different data types const mixedArray = [1, 'chicken', false]; |
| Method .push() | Adding one or more elements to the end of an array. // Adding multiple elements: const numbers = [1, 2]; numbers.push(3, 4, 5); console.log(numbers) // [1, 2, 3, 4, 5 ] |
| Method .pop() | This method removes the last element from an array and returns that element. const ingredients = ['eggs', 'flour', 'chocolate']; const poppedIngredient = ingredients.pop(); // 'chocolate' console.log(ingredients); // ['eggs', 'flour'] |
| Mutable | JavaScript arrays are _____ meaning that the values they contain can be changed. |
| Logical Not Operator | The ________ ! can be used to do one of the following: Invert a Boolean value. Invert the truthiness of non-Boolean values. |