Functions - Reading Assignment

a function part of the code starts with tthe keyword funtion and then you can mocve on adding vairibles

the let is a local declaration and the var is a global one, you can use let in a function and var in the whole thing

a pure funtion is in a bubble and it wont be affected by let or var commands im pretty sure

1 Like
  1. How can you create a function in Javascript?
    It’s an expression that starts with keyword function.
    Functions has set of parameters like body, which contains the statements that are to be executed when the function is called.

  2. What is the difference between var and let in regards to scope?
    var defines a variable globally or locally to an entire function regardless of block scope.
    let allows to declare variables that are limited in scope to the block, statement, or expression on which it is used.

  3. What is a pure function?
    it’s a specific king of value-producing, it doesn’t produce or rely on side effects, it doesn’t read global binding. It had property, that when it’s called for the same arguments it produces the same value, without changing the meaning of the code.

1 Like
  1. How can you create a function in Javascript?
    You can create a function just by writting : “function.” The function can have parameters but it can also not have any parameters.
  2. What is the difference between var and let in regards to scope?
    The difference between let and var is that let will be only a variable for a specific block. Whereas “var” will be used for the whole program let will be used for a block in the program.
  3. What is a pure function?
    a pure function is a function that when called with the same argument it will always give the same value.
2 Likes
  1. Is created with an expression that starts with the keyword function, followed with a set of parameters and a body, which contains the statements, and is always wrapped in braces. The function keyword, can be used a)as an expression) as a statement, and c) arrow.
  2. Parameters and bindings declared with let are local and not visible from the outside, while bindings, created with var keyword, are visible throughout the whole function or the global scope, if they are not in a function.
  3. Pure is a function that has no side effects and also doesn’t rely on them. When it is called with the same arguments, it always produces the same value and it’s easy to test if work in context
2 Likes
  1. A function is created with an expression that starts with the keyword function. It can have a set of parameters and a body, which contains the statements that are to be execute when the function is called.

  2. Var is a function scoped and let is a block scoped. It can be said that a variable declared with var is defined throughout the program as compared to let.

  3. A pure function is a function which given the same input will return the same output, produces no side effects.

1 Like
  1. By defining a binding equal to a “function” expression, plus the function body between braces. For example:
const myFunction = function(parameterOne, parameterTwo) {
console.log(parameterOne);
return parameterTwo;
};
  1. The scope of “let” is only the block that contains it, while the scope of “var” is the whole function.

  2. Pure functions are value-producing functions that don’t produce nor rely on side effects from other code.

1 Like

A function can be created by delaring it and adding a body: function greet (“Sup wit it”)
Let is a local binding and var is global
A pire function operates outside os the global.scopr

1 Like
  1. Use the function keyword, either use it first in an expression followed by the function name and its parameters, or declare a variable and set it equal to the function keyword and the parameters.
  2. var declares a variable that is global in scope where a variable declared with let will only be defined in its current function or block.
  3. A pure function returns an output without producing any side effects and the output will be the same if the input is the same every time it is called regardless of the current environment it is in.
1 Like
  1. A function is created with an expression that starts with a keyword ‘function’. Functions have a set of parameters, and a body which contains the statement that are to be executed when the function wrapped in braces ‘()’ even when it consists of only a single statement. A function can have multiple parameters or no parameters at all.
    2.difference between ‘var’ and ‘let’ in regards to the scope. Each binding has a ‘scope’ which is the part of the program in which the binding is visible. For bindings defined outside of any function or block the ‘scope’ is the whole program and these are called ‘global’ and referenced in a program as either ‘let’ or ‘const’. But bindings created for function parameters or declared inside a function can be referenced only in that function and these are called ‘local’ and referenced as ‘var’.
    3.A ‘pure function’ is a specific kind of value-producing function that not only has no side effect but also doesnt rely on side effects from other code, for example, it doesnt read global bindings whos value might change. A pure function has the property that, when called with the same argument , it always produces the same value( and doesnt do anything else).
1 Like
  1. How can you create a function in Javascript?
    A function is created with an expression beginning with keyword ‘function’. A complete function will have a set of parameters and a body, which contains statements which are to be executed when function is called. A return statement determines the value the function returns.

  2. What is the difference between var and let in regards to scope?
    Bindings declared with let and const are local to the block they are declared in. Bindings created with var are visible throughout whole function they appear in - or throughout global scope.

  3. What is a pure function?
    A pure function is a specific kind of value producing function that has no side effects and doesn’t rely on side effects from other code. For example it doesn’t read global bindings whose value might change. A pure function has the property that, when called with the same argument , it always produces the same value (and doesn’t do anything else).

2 Likes
  1. you can create a function by calling a const giving that const a name and then write equals then you type function(…){ with the action that it has to do} so it looks like this:
    function functionName (parameter1,parameter2…){set of instructions}

  2. the difference between a VAR and a LET in a scope. Is that VAR is visible outside of the scope. And LET is only visible within the function/scope.

  3. when you give a pure function the same input it always gives the same output, it has no side effect.

1 Like

1-
As an expression: const a = function(b) { return b }
As a statement: function a(b) { return b }
As an arrow: const a = b => b

2- var scope continues existing outside a block, let scope only keep inside blocks

3- Pure functions are a function which only read and write its own scope, they don’t rely on read or write bindings outer their scope and don’t make any side effects. Easy to test and very reliable

1 Like
  1. A function is made using an expression that starts with the keyword function and has a body which contains statements to be executed. There can also be parameters assigned to the function to help it run according to specific guidelines.

  2. With var in regards to scope they affect the nearest function scope or the global scope. The let binding affects a local scope and does not affect the global scope.

  3. A pure function has no side effects and does not depend on side effects from other code to process. When called, it always returns the same value because it is not affected by global bindings that may change.

1 Like
  1. A function is created with an expression that starts with the keyword function
    Functions have a set of parameters and a body, which contains the statements that are to be executed when the function is called.
  2. Let is used in block, var is global.
  3. A pure function is a specific kind of value-producing function that not only
    has no side effects but also doesn’t rely on side effects from other code.
1 Like

1.A function is created with an expression that starts with the keyword function. Functions may or may not have a set of parameters.
2. let allows you to declare variables that are limited in scope to the block, statement, or expression on which it is used. var keyword defines a variable globally, or locally to an entire function regardless of block scope.
3.A pure function is a specific kind of value-producing function that not only
has no side effects but also doesn’t rely on side effects from other code—for
example, it doesn’t read global bindings whose value might change.

1 Like
  1. function funtionName () {instructions}
  2. let are variables that are limited to a block
  3. a pure function always returns the same result
1 Like
  1. The function keyword, when used as an expression, can create a function value. When used as a statement, it can be used to declare a binding and give it a function as its value. Arrow functions are yet another way to create functions.

  2. let defines a variable that is limited to a specific block, whereas var defines a variable globally or locally but then to the entire block.

  3. A pure function is a specific kind of value-producing function that not only has no side effects but also doesn’t rely on side effects from other code.

1 Like
  1. A function is created by assigning an operation to a constant. That is done by creating an expression that starts with the keyword function.

  2. Var has a global scope, while let has a local scope on the code.

  3. A pure function is a type of function that produces a value and does not rely on other parts of code to produce its value. It always produces the same value when run with the same parameters.

1 Like
  1. How can you create a function in Javascript?
    We can create a function by using the keyword “function”,giving it a name, giving it a parametar, argument () and a body {} which contains the statements that are to be executed when the function is called.
    We can do it as an expression, as a statement, as an arrow.
  2. What is the difference between var and let in regards to scope?
    Difference between them is that the LET is only visible within the function that it is created in and VAR can be called from outside the function.
  3. What is a pure function?
    Pure functions are a function which only read and write its own scope, they don’t rely on read or write bindings outer their scope and don’t make any side effects. Easy to test and very reliable. When it is called with the same arguments it always produces the same value.
1 Like
  1. How can you create a function in Javascript?
    A function is a piece of program wrapped in a value, and a function is created with an expression that starts with the keyword function. You can call a function by putting parentheses after an expression that produces a function value.
  2. What is the difference between var and let in regards to scope?
    In functions, arguments (code to be executed) behave as local variables. In regards to scope, the function let declares a variable limited to the block, statement, or expression on which it is used. The function var on the other hand defines a variable globally, or locally to an entire function regardless of block.
  3. What is a pure function?
    A pure function is a specific kind of value-producing function that not only has no side effects but also doesn’t rely on side effects from other code—for example, it doesn’t read global bindings whose value might change. A pure function has the pleasant property that, when called with the same arguments, it always produces the same value (and doesn’t do anything else).
1 Like