Variables and Data Types in Javascript
This is a study note about Javascript from https://www.geeksforgeeks.org/introduction-to-javascript-course-learn-how-to-build-a-task-tracker-using-javascript/
Javascript is untyped language. Once a variable is created in javascript using 'var', you can assign any other type of data to this variable.
Above code is valid in Javascript. Variable text can be assigned a string value and then later change to a number.
1. Difference between var and let in Javascript
Basically, 'var' is function scoped, however 'let' is block scoped.
https://www.geeksforgeeks.org/difference-between-var-and-let-in-javascript/
Let's use use 'let' for most of the cases because 'var' is confusing.
2. Number type in Javascript
The number type in Javascript contains both integer and floating point numbers. Besides these numbers, we also have 'special-numbers' in Javascript that are: 'infinity', '-Infinity' and 'NaN'. The 'NaN' denotes a computational error.
3. String type in Javascript
There are three types of quotes in Javascript:
There's no difference between 'single' and "double" quotes in Javascript. Backticks provide extra functionality as with the help of them we can embed variables inside them.
4, Undefined type in Javascript
The meaning of undefined is 'value is not assigned'.
5, Object type in Javascript
Everything in Javascript is Object. There are two ways to create objects.
You can initialise object with properties like below:
Comments
Post a Comment