-
What is the difference between const and let? and why don't we use var?
-
What does return and console.log do inside a function and what is the difference between them?
-
What is a paramater in JS function and why is it there?
-
What are truthy and falsy values in JS? give some example on each
-
What is the difference between abstract equality comparison (==) and strict equality comparison (===)?
-
-
Save halitbatur/b55bc4763eaba8fce39867937fd4d81e to your computer and use it in GitHub Desktop.
Q1:
Let is changeable but const is unchangeable, var declarations are globally scoped or function scoped while let and const are block scoped
Q2
console.log is function that logs passed in argument to console.
return is keyword, which part of the return statement, used to end function execution.
Q3
The parameters, in a function call, are the function's arguments.
JavaScript arguments are passed by value: The function only gets to know the values, not the argument's locations.
If a function changes an argument's value, it does not change the parameter's original value.
Q4
Basically, if the variable value is false, zero, empty, null, undefined,””, or Nan, it's falsy and the code within the if block is not run.
If the variable value is anything else, such as a number that is not zero, a non-empty string, an array,”Text” or an object, it's truthy and the code in the if block is run.
Q5
The difference between them can be summed up as follows:
- Abstract equality will attempt to resolve the data types via type coercion before making a comparison. ==
- Strict equality will return false if the types are different. ===
Ex:
4 == "4"
>> true
4 === "4"
>> false
Sanad,Amany, Sara, Dana and Mohmmad
1:
-the difference between const and let is that const have to be initialized and its value can't be changed later on,
-on the the other hand the let don't have to be initialized and its value can be changed,
-meanwhile the var isn't used due to its scope issus, like when redeclaring a variable the same name using var the second variable value will always be used.
2:
-console.log just prints whatever argument given to it on the console, doesn't affect the flow of the function, used for debugging purposes.
-return returns the value to the caller whether be it a function or a variable, exit the function immediately after its execution,
3:
-increases/improves usability ,reusability, abstraction and Interactivity.
4:
5:
-== checks for value equality with type coercion.
-=== checks for value equality without type coercion (i.e., it checks both value and type).