Intro Flashcards
Where is the main place where javascript is used? What also?
In the web. business and even for games
What is typescript?
It is a superset of javascript (used for business)
What is necessary after cloning a javascript project?
npm install
What happens when you do a npm install?
the npm will install all “devDependencies” from packages.json
Where are the npm dependencies installed?
installed in the node_modules folder
How to start the web application?
npm run start
What happens when you save the file?
it refreshes the page
How to import javascript to the html?
Where to place a javascript file that can manipulate a website?
In the end of the html (but still above html tag)
Will spaces and tabs break the javascript?
No… it won’t matter.
How to see javascript errors?
In the inspect element, console tab.
What happens when an expection happens in the javascript file?
The javascript execution is halted
How to output logs to the browser?
Via the console.log(“my message”)
Is javascript case sensitive?
Yes.
How javascript methods are capitalized?
likeThisGotIt()
How to do single and multi line comment in javascript?
//single
/*
multi
line
*/
How to declare a variable? How it was declared in the past?
let = total 149.99;
it was declared as var in the past. DO NOT USE IT ANYMORE.
How to declare multiple variables?
With commas. e.g:
let price = 50, name = 'Name here';
Can I start a variable that starts with a number?
No.
Should we use camelCase to declare variables? How do we start a variable that is internal?
Yes.. e.g: thisIsMy = ‘Var’; Internal/private vars start with _myPrivVar;
When start a variable with a $ sign?
Used only for auto-generated code.
Is it a good practice to always declare vars along with their values? What happens when you declare a var without initialization?
Yes. It becomes undefined.
Can a const variable change? Have we to set a value in the declaration?
No. Yes. e.g:
const price = 50;
What happens when we use a variable too soon (before declaration) using var and let?
var shows no error, becomes undefined. and let throws an error.
What are types and operators?
types are how the data is structured and operator is some sort of processing the types (e.g: + sign)
What does the typeof keyword does?
outputs the type of the variable, e.g: typeof price is integer.
How to do addition, subtraction, multiplication, division and remainder (modulus) in JS?
+, -, *, /, %
How to do a mathematical operation with the variables without retyping it?
price += 10;
note: works for all math operators.