Great job on starting a new lesson! In the FAQ, test yourself by clicking the correct answer for each question. Then, click Next button at bottom right to continue.
Javascript Variables
JavaScript variables store data and allow you to manipulate it. Once you store data in a JavaScript variable, you can refer to that data by its variable name. JavaScript variables can hold different types of data. JavaScript variable types are strings, numbers, booleans, arrays, and objects.
What are the variables in JavaScript?
Variables are the names to refer to specific memory locations. Variables in JavaScript are case sensitive, meaning JavaScript variable names "myVariable" and "myvariable" are different. The scope of a variable determines its reach or accessibility within the code. JavaScript supports both global and local variable scope. When naming variables, it's recommended to use descriptive names and follow naming conventions such as using camelCase.
JavaScript Example: Variable Declaration
// Create a HTML text file and put the following within <script> and </script> tags. // Open your HTML file in your browser. Open Developer Tools > Console. // JavaScript variable declaration var name = "Jane"; var age = 24; var isStudent = true; var numbers = [1, 2, 3]; var student = { name: "Jane", age: 24 }; console.log('The student name is ' + name); console.log('The student age is ' + age); console.log('isStudent: ' + isStudent); console.log(numbers); console.log(student);
FAQ (Interview Questions and Answers)
-
Are JavaScript variables case sensitive?
No
Yes
Sometimes
-
What is the scope of a JavaScript variable?
Class scope
Global and local scope
File scope
-
What is the recommended naming convention for JavaScript variables?
camelCase
UPPER_CASE
kebab-case
-
Can a JavaScript variable hold multiple values?
No, it can only hold a single value.
Yes, using arrays.
Yes, using objects.
-
What type of data can a JavaScript variable store?
Different types like strings, numbers, booleans, arrays, and objects.
Only strings and numbers.
Only strings.
Your Total Score: 0 out of 5
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.