LS 101 Flashcards
LS101 Methods, Terminology, and Concepts
What is the difference between Git and Github?
Git is a distributed version control system designed to be used locally without a central repository.
Github is a cloud based remote repository which acts as a centralized repo for git to enable collaboration.
When should you nest Git repositories?
You should never nest Git repositories
What are the built-in (primitive )JavaScript data types?
String, Number, Boolean, Undefined, Null
Does Javascript have Integer and Float specific Numeric data types?
No. Every numeric value has the primitive type of Number and is represented using a floating point number system.
Are all primitive values immutable?
Yes. String, Number, Boolean, Undefined, and Null are all immutable.
Is NaN a primitive value?
Yes. NaN is technically a number so it is a primitive.
Does this contain a statement, an expression, or both?
Both.A variable declaration with an optional assignment is an expression.Anything valid to the right of = is an expression, so 3 is an expression.
The code to the right of the assignment operator =
is an ??????????.
an expression
Is the reassignment of myVariable from a String to a Number valid since they are different data types?Is the original value (‘Hello, World’) changed by the reassignment?
No, JavaScript variables are not type specific.No, that is a primitive so the reassignment either creates a new value or assigns the variable to refer to an object.
When using == to compare a number and a string, what happens as far as coercion?
The string is always coerced to a number regardless of which side the number/string is on and then the comparison is made using === with the coerced value.
What is the return value in JavaScript of coercing a non numeric string (“blue”) to a number?
NaN
What does typeof NaN return?
number, NaN is an instance of the primitive type number
Return Values:
The return values are different since theletstatement always returnsundefined, but assignment expressions that aren’t part of a statement return the new value for the variable.
What is always the return value of a let/const statement?
undefined
What is the return value of this snippet:
undefined. an assignment using the let keyword will always return undefined.
What is the return value of this snippet:
false, an assignment not using the let/const/var keyword always returns the value on the right side of the =.
How do you create a single line comment in JavaScript?
use // to make the entire line a comment
What is best practice for max line length in JS?
80 characters
What formatting is used for variable names and function names?
camelCase
What is different about the naming convention for a constructor function?
You use PascalCase instead of camelCase.
What is different about the naming convention for a constant?
You use SCREAMING_SNAKE_CASE to name a constant
What are the only type of characters that should be used when naming variables, constants, and functions in JavaScript?
Alphanumeric characters (a-z, A-Z without accents) and numeric characters.When naming a variable the first character should ALWAYS be alphabetic.Constants may use underscores$ is allowed in names but only in specific cases, they are legal but should not be used in general.
let 5Miles = 5280 * 5;is this a valid variable declaration?
The declaration will work but you shouldn’t ever start a variable/function name with a numeric character.
Does this snippet adhere to code the JavaScript style guide:
Yes, there must be a space between the key word and condition check and it is best practice to put a space between the conditional and the opening curly bracket.