Variables Variables are used to store data values . Variables have: Name Datatype Value JavaScript uses the keywords var and/or let to declare variables. An equal sign/assignment operator (=) is used to assign values to variables. Example: var age; age=15; Note: JavaScript does not interpret LET or Let as the keyword let.
JavaScript Keywords JavaScript keywords are used to identify actions to be performed. Some JavaScript keywords are: let var
JavaScript Identifiers Identifiers are used to name variables and keywords. Identifiers can be short names (like x and y) or more descriptive names (age, lastname , customeraddress ). The rules for the naming JavaScript Variables JavaScript name can contain: A letter (a – z or A – Z) A dollar sign ($) An underscore(_) JavaScript name must begin with letter. Note: JavaScript identifiers are all case sensitive.
Data Types Unlike its predecessor languages C, C++ and Java, JavaScript does not require variables to have a declared type before they can be used in a script. A variable in JavaScript can contain a value of any data type, and in many situations JavaScript automatically converts between values of different types for you.
Declaring a JavaScript variable Creating a variable in JavaScript is called “declaring” a variable. var and let keywords are declaring variable. Example: var age; or let age;
Arithmetic operators Addition & Subtraction <script> let x=5; let y=3; let z= x + y; let m= x - y; console.log(z); console.log(m); </script> Multiplication & Division <script> let x=5; let y=3; let z= x * y; let m= x / y; console.log(z); console.log(m); </script>
Comparison/Relational Operators <script> let x=5; let y=3; console. log(x> y); console.log(x<y); </script>
Logical operator <script> let x= true && true; let y= true || false; let z=!false; console.log(x); console.log(y); console.log(z); </script>