JavaScript Flashcards
(55 cards)
What are es6 and es7 in JS
Es stands for ECMAscriptn
And they are two versions or updates of js
Es6 is in 2015
Es7 is in 2016
Each one added different features
How do you connect your JS with your code ?
Script tag
Src
In the body at the end
How to use DOM functions to point to html elemets
document.getelementbyid
Getelementsbyclassname
Queryselector
Queryselectorall
What is $ used for in js
Allows you to embed variables inside a string , so changing variable within a static string
Explain destructuring objects(say the syntax)
It is a way to extract values from objects or arrays and assign them to variables using shorter syntax.
What type of data can you have in an object
Numerical
Objects
Array
String boolean
Null
Undefined
How to use destructuring when you have nstead objects?
Const{objectName:{key}}=big object name
What are the components of an object
Const object ={ Key:value, ———}
And const object can change values inside
How does destructuring work in array?
So as said we are initializing values in easier sytax
const [name]=array name, or [array]
Now name will point to the first element in the array
And you can add other variables after name to point to other values in the array in order
How can you shorten the syntax of an object inside a function and what do you call it
You do const object={ parameter1,parameter2,…..}
This will make the object have the parameter name as key and the passed value through the the value of that key.
call Object Property Shorthand
What is template literal
a feature added in es6 that allows you to imped variables in strings, concatenate strings, help with readability, and multi line string while using the backtick
What is for of loop and what is it’s syntax
A loop where you can iterate through stuff like strings are arrays easily
The syntax is for (let/const anyname of array name or string name)
{Do work here (the name you chose will point to each array element and you can do whatever you want, but it will not modify the array it self, so it will be a variable pointing to the array elements not referencing to the actual array}
What is ‘ called
Backtick
Why is backtick better than “ or single quotation
Because it is one of the template literature that allows text formatting happen like spaces and new lines.
Any thing you write inside will be written in the console like you wrote.
Without backtick you cannot use variables inside {}
How to do a new line in console log when using a “ or single
By \n
Talk about spread operator
Now when you make an array =array1
Array will now reference to it
But with spread operator you shallow copy the content of the array to a new array and you can modify stuff.
array=[…array1]
can also used with objects
you can merge, over ride, add new values or just simply copy , using spread operator
Does spread operator work to copy objects?
Yes
So …name
Means copy all the data inside
What is arrow function
A way to make a function but anonymously
What are the ways to make a function
unanimously:
const camelCase= function (){}
Or
Const camelCase= ()=>{}
normal:
function camelCase (parameters)
How to make a normal function in js
function name () {}
What is the implicit return feature in fucntions
When you have only one line in the function and you just write it without return or {} (only for arrow) not named functions it will consider it as return automatically
Explain this
const name = (food=something)=>{} and what do you call it
This means when you forget to pass a parameter your parameter will be automatically set to something, if you pass, it will be updated
Called default parameter
Explain includes() function
Will return true or false , will iterate through an array and check if it has that value or not
What do you need to do imports and exports when working with js?
You need nodejs at least vs 12
Check node —version
And you name your files .mjs
M is for module
add type ‘module’ is your script tag and don’t forget to put .mjs in src