Questions tagged [let]

In Lisp-like and functional languages, introduces a list of local variables, each (possibly optionally) with its initial value.

In Lisp-like and functional languages, introduces a list of local variables, each (possibly optionally) with its initial value. It is illegal to refer to any of the new variables while calculating their initial values ( lets you do that), though in Haskell it is legal (its let is actually letrec).

LET is a special form in Common Lisp, Scheme, Clojure and other Lisp dialects which introduces a list of local variables as pairs of name-value bindings, for use within its body. For instance, in this expression:

(let ((variable1 (+ 1 1)))
  variable1)

variable1 gets bound to the 2 value, and the whole expression returns 2 as a result.

728 questions
-2
votes
2 answers

How and when does kotlin let run?

for all the examples on the internet i cant figure out when and how is kotlins let ran? if(phones.size == 0){ phones.add("") } return phones[0] so if phones list size is 0, we add empty string and return that instead. Now how would one…
Clomez
  • 1,410
  • 3
  • 21
  • 41
-2
votes
2 answers

Why global let declarations get overridden by unscoped variables?

When we create a variable without specifying let or var it gets added to window object in browser. For example function change(){ val = 20; } change(); console.log(window.val); //20 console.log(val); //20 Here I am getting both…
Vineesh
  • 3,762
  • 20
  • 37
-2
votes
1 answer

Expected an identifier and instead saw 'let'

I am trying filter the object and when I do it I am getting this error what actually it is saying I am not getting it. Expected an identifier and instead saw 'let'. This is my filter function var arr = $scope.items; //object data var…
Mr world wide
  • 4,696
  • 7
  • 43
  • 97
-2
votes
1 answer

Javascript let hoisting to the scope or creating where it is?

x declared after fn function but returns its value. Why fn didn't return undefined? function doWork(){ let fn = function(){ return x; } let x = 2; return fn(); } console.log(doWork()); // 2
uzay95
  • 16,052
  • 31
  • 116
  • 182
-2
votes
2 answers

printing list values using let in clojure

how can I print list elements using let keyword in clojure language? (defn build-headline-keywords-item [es-client conf common-item headline] (let [headline headline] (println (:headline)) (es/upsert es-client conf (merge common-item{:source…
shivani thakur
  • 219
  • 1
  • 3
  • 12
-2
votes
1 answer

swift static constant variable change cause recompiled

In swift if I have a global constant such as let host = XXX in a file, the change of this constant will cause all project files recompiled
李剑伟
  • 1
  • 1
-3
votes
1 answer

JavaScript- let showing name instead of value

I am a beginner and Started learning JavaScript today. I tried from a tutorial: let a = 1 console.log('a') Now,when I run it, the answer should be the value which is 1, but it shows me the name instead which is a. What I am doing wrong?? I am using…
-3
votes
3 answers

JS calling ID by variable

Hi All First data: let NewDivForGame_0 = document.createElement('div'); let NewDivForGame_1 = document.createElement('div'); let NewDivForGame_2 = document.createElement('div'); and so on...12 Next: NewDivForGame_0.id = 'Key'; …
KimL
  • 1
  • 2
-3
votes
2 answers

Rewrite code without using let javascript

Assuming reassignment of variable can lead to bugs what hard to debug, I am looking for options not to use let in this example. Please advice. function getNodeById( optionsList: F[], nodeId: string): F | null { let…
-3
votes
1 answer

Cannot assign to property: 'desc' is a 'let' constant

I have a problem with an error described in the title - "Cannot assign to property: 'desc' is a 'let' constant". I would like to assign a string variable to 'desc' in a JSON file. JSON was previously downloaded to a variable named "result". I have…
MatoNator
  • 1
  • 1
  • 4
-3
votes
1 answer

how to use a variable value as a property in an JS object

in JS I would like to use a variable value as a property in an object. for example: let myVar='toto'; let myObjet={ toto:['1', '2','3'], tata: ['a','b','c'] } //I want to recover the array of toto property…
-3
votes
1 answer

Is var the only option we have for declaring global variables and functions?

On this page: I found that it is important to use var and we can not use let and const for declaring global variables and functions but I tried to do use let and const. So should I use them or they are not recommended? Here is my code that I…
-3
votes
1 answer

Why the alert is showing undefined after fred flinston? and what properties does "const" in ES6 have?

let a = 'Fred Flinstone'; // This is a global variable function alpha() { alert(a); } alert(alpha()); why the following code displaying undefined after displaying fred flinston? and what properties does "const" in ES6 have and what is meant by "…
-3
votes
1 answer

What is scope default of a variable defined by JavaScript var?

What is the scope of the default variable in javascript? I'm confused, I would like to know what Alcanse has the default variables I think is var or not? For example: x = 15 // ?? let y = 22 // let var j = 33 // var var? let?
-3
votes
1 answer

Comparing two variables JavaScript

I am new to programming and JavaScript so please bear with me if its a stupid question. I initialised two variables let firstName = "blah"; let FirstName = "bleh"; When i write a below if statement i expected the output to be "right on" since the…
Prashanth
  • 11
  • 2
1 2 3
48
49