Skip to content

Instantly share code, notes, and snippets.

@halitbatur
Created March 16, 2023 13:40
Show Gist options
  • Save halitbatur/b55bc4763eaba8fce39867937fd4d81e to your computer and use it in GitHub Desktop.
Save halitbatur/b55bc4763eaba8fce39867937fd4d81e to your computer and use it in GitHub Desktop.
Discussion Questions about JS

JS basics discussion

  • 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 (===)?

@Sanad-Alshobaki
Copy link

Sanad-Alshobaki commented Sep 25, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment