Back to articles
Variables in JavaScript 101

Variables in JavaScript 101

via Dev.to BeginnersPetrina Ropra

Disclaimer: I am not a professional software engineer nor a computer science student. This is more of what I understand about variables in JavaScript from what I read on MDN Web Docs. JavaScript Variables A variable is like a label that points to a certain space in the computer's memory. When you assign a data type or object to a variable, it goes into that space. Declaring Variables A variable is declared using one of these three keywords: var , let or const . var — unpredictable and highly recommended NOT to use let — use only when you are 100% sure you will reassign a new value later on const — the default choice; always use this unless you need to reassign Naming Variables There are a few rules and best practices to follow when naming variables: Names can only start with a letter, underscore ( _ ) or dollar sign ( $ ) — any other character will throw an error Names cannot contain spaces. For example, let my name = "Athena" is not allowed Names are case sensitive — num , Num and NUM

Continue reading on Dev.to Beginners

Opens in a new tab

Read Full Article
7 views

Related Articles