Javascript Flashcards
How would you create a .js file named Digital Nomad from the terminal?
touch digital-nomad.js
How would you run a js file named digital-nomad.js from the terminal?
node digital-nomad.js
What is the difference between shell REPL and the node REPL?
The shell REPL executes system commands, while the node REPL executes JavaScript. You can’t use the shell to execute JavaScript, and you can’t use node to execute system commands.
How would you write a comment in Javascript code?
// Comment goes here
What are two ways we would name a constant in JavaScript?
CamelCase (PascalCase) or ALL_CAPS_LIKE_THIS
In JavaScript, there are seven fundamental data types: what are they?
Number, String, Boolean, Null, Undefined, Symbol, Object
Explain the Number Datatype:
Any number, including numbers with decimals: 4, 8, 1516, 23.42.
Explain the String Datatype:
Any grouping of characters on your keyboard (letters, numbers, spaces, symbols, etc.) surrounded by single quotes: ‘ … ‘ or double quotes “ … “. Though we prefer single quotes. Some people like to think of string as a fancy word for text.
Explain the Boolean Datatype:
This data type only has two possible values— either true or false (without quotes). It’s helpful to think of booleans as on and off switches or as the answers to a “yes” or “no” question.
Explain the Null Datatype:
This data type represents the intentional absence of a value, and is represented by the keyword null (without quotes).
Explain the Undefined Datatype:
This data type is denoted by the keyword undefined (without quotes). It also represents the absence of a value though it has a different use than null.
Explain the Symbol Datatype:
A newer feature to the language, symbols are unique identifiers, useful in more complex coding.
Explain the Object Datatype:
Collections of related data.
What is a method? & Give an example
A Method is an action we can perform. Example: E.g. ‘example string’.methodName().
Say you have this variable let nomad = ‘Digital Nomad’; How would you do string interpolation.
console.log(My name is Daniel and I am a ${nomad}
) we have to use backticks