What is the difference between Let and Var ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the difference between Let and Var ?

Lesson does not show clearly the differences between Let and Var .

19th Nov 2017, 12:16 AM
Ever Jung
Ever Jung - avatar
6 Answers
+ 3
Oops.. sorry, missed that tag, could've helped if it says "Swift" rather, sorry everyone :)
19th Nov 2017, 5:25 AM
Ipang
+ 3
Haha.. @Ipang, I made the same mistake too, always thought that let and var belong to JavaScript. I deleted my answer now.. 😜
19th Nov 2017, 5:31 AM
Calviղ
Calviղ - avatar
+ 2
It clearly shows the difference. let indicates constant variable, which is not to be changed. var is just regural variable.
19th Nov 2017, 1:35 AM
Jakub Stasiak
Jakub Stasiak - avatar
+ 2
let creates a constant. Once the value is set to a let identifier it cannot be changed unlike a var.
19th Nov 2017, 1:35 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Ok !!! thanks I had understood constant was entered with Int.
19th Nov 2017, 1:53 AM
Ever Jung
Ever Jung - avatar
+ 1
@Ipang Swift not Javascript. let is different in Swift then it is in Javascript.
19th Nov 2017, 5:12 AM
ChaoticDawg
ChaoticDawg - avatar