JavaScript Basics Flashcards
What is JavaScript?
JavaScript is a powerful, flexible, and fast programming language used for interactive web development
Define the Console.
The console is a panel that displays important messages, like errors, for developers.
If we want to see things appear on our screen, we can print, or log, to our console directly.
Keywords are words that are built into the JavaScript language, so the computer will recognize them and treats them specially.
What is the purpose of a semi-colon in a line of code?
The semicolon denotes the end of the line, or statement.
Define a comment.
Comments can explain what the code is doing, leave instructions for developers using the code, or add any other useful annotations.
These comments exist just for human readers.
2 types of comment?
A single line comment will comment out a single line and is denoted with two forward slashes // preceding it.
A multi-line comment will comment out multiple lines and is denoted with /* to begin the comment, and */ to end the comment.
Name the 6 primitive data types.
Number String Boolean Null Undefined Symbol
Define a data type.
Data types are the classifications we give to the different kinds of data that we use in programming.
There are 7 fundamental types
What does the “string” datatype involve?
String: Any grouping of characters on your keyboard (letters, numbers, spaces, symbols, etc.) surrounded by single quotes: ‘ … ‘ or double quotes “ … “
What does the “Boolean” datatype involve?
Boolean: This data type only has two possible values— either true or false
What is the Null datatype?
This data type represents the intentional absence of a value, and is represented by the keyword null
What is the Undefined datatype?
This data type is denoted by the keyword undefined and represents an intentional absence
What is the Symbol datatype?
Symbol: A newer feature to the language, symbols are unique identifiers, useful in more complex coding.
What is the Object datatype?
Object: Collections of related data.
Define an operator?
An operator is a character that performs a task in our code.
What is an arithmetic operator?
Built-in arithmetic operators allow us to perform mathematical calculations on numbers.
Name 5 arithmetic operators.
Add: + Subtract: - Multiply: * Divide: / Remainder: %
What is String Concatenation?
The process of appending one string to another. When a + operator is used on two strings, it appends the right string to the left string:
Define a Method.
Methods are actions we can perform. JavaScript provides a number of string methods.
We call, or use, these methods by appending an instance with:
a period (the dot operator)
the name of the method
opening and closing parentheses
e.g. .startsWith()
What does the Number datatype categorise?
Numbers are any number without quotes
What is the dot operator?
We can access properties and methods by using the ., dot operator.
What does the “Var” keyword do?
Short for variable, is a JavaScript keyword that creates, or declares, a new variable.
What is camel casing?????????????
Camel casing is when you bunch words up together to form a string of code.
The first word is lowercase, the following is Capitalized
e.g. .startsWith()
.myName()
Example of an assignment operator.
=
What does the “Let” value do?
The let keyword signals that the variable can be reassigned a different value.
What does the “Const” variable do?
A const variable cannot be reassigned because it is constant. If you try to reassign a const variable, you’ll get a TypeError.
What does the increment operator do?
The increment operator will increase the value of the variable by 1. ++
What does the decrement operator do?
The decrement operator will decrease the value of the variable by 1. –
What is a variable?
Variables hold reusable data in a program and associate it with a name. Variables are stored in memory.
What are Conditional Statements?
A conditional statement checks a specific condition(s) and performs a task based on the condition(s).
What does the “if” conditional statement do?
It will perform an action based on whether a statement is true.
What does the “else” conditional statement do?
It will perform an action based on whether a statement is false, as an alternative action.
What are comparison operators?
Different types of operators used to compare values.
Comparison operators compare the value on the left with the value on the right. For instance:
10 < 12 // Evaluates to true
Name 3 logical operators.
And (&&), or (||), not ( ! )