Ultimate JavaScript Mastery - Part 1 Flashcards
What is JavaScript?
A programming language written to be executed within the browser
What can you do with JavaScript?
Modern JavaScript can also be used as a server side language as well as front end
Where does JavaScript code run?
Originally meant to run only in the browser, but can now be run outside the browser using node
Describe the difference between JavaScript and ECMAScript
ECMAScript is simply the standard for which JavaScript, a programming language, is written
Where should you place your tag within the browser?
The tag should be written at the end of the body section.
What is a statement?
A piece of code that expresses actions to be carried out.
Write a script tag
What are the data types in JavaScript?
Primitive (Value) Types and Data Types
Name the Primitive (Value) Types
String Number Boolean undefined null
Describe Dynamic Typing
JavaScript is a Dynamic Programmming language because variable types can be changed
Name the Reference Types
Object
Array
Function
What is an object?
A piece of code that stores data via key/value pairs. The keys are known as the properties of the object.
A key in an object is also known as what?
Property
What are the two ways to access properties within an object?
Dot Notation
ex. person.name = “Kevin”
Bracket Notation
ex. person[‘name] = “Kevin”
What are the names of the JavaScript operators?
Arithmetic - takes two operands and produces a new value (+, -, *, /, %, ++, –)
Assignment - assigns a value to a variable (=, +=)
Comparison - A comparison between to expressons that returns a boolean value such as ‘true’ or ‘false’ (>, >=,
Give an example of a ternary (conditional) operator
A ternary operator can evaluate an expression and provide two an option if it is true, and an option if false ex if(age >=21 ? "Old Enough" : "Too Young")
What are “falsy” values?
Any expression that evaluates to any of the following will return false.
undefined null 0 false "" NaN
What is an advantage of using non the logical “or” ( || ) operator with non boolean values?
Using the logical “or” ( || ) with non boolean values will allow you to set default values. For example, if something doesn’t exist, you can have a default value set. For example, If a user hasn’t signed in, you can set mount a default component such as the login
What are the 2 conditional statements?
If...else if(condition) { statement } else if { statement } else { statement }
switch..case let name = "Kevin" switch (name) { case "Kevin" : console.log("Hello, Kevin"); break;
case “Preye” : console.log(“Hello, Preye”);
break;
default: console.log(“Hello, guest”)
}
Describe the difference between “==” and “===” operators
The “===” operators evalueates both value and type, whereas “==” evaluates just value.
What are the 5 kinds of Loops?
For
While
Do…While
For…of
What is the anatomy of a for loop?
The for loop requires 3 statements within the parenthesis
for (let i = 0; i <= arr.length; i++) { console.log("Hello World") } for (initalExpression; condition; incrementExpression) { statement }
How is a while loop different from the for loop?
Within a for loop, the loop variable (i) is apart of the loop itself. The while loop, however, has to be declared outside of the loop.
let i = 0; while(i<=arr.length) { console.log(i); i++ }
Construct a “do…while” loop
let i = 0 do { if (i % 2 !== 0) console.log(i); i++; } while (i < = 5);