Podcast
Questions and Answers
Which characters are allowed in variable names in JavaScript?
Which characters are allowed in variable names in JavaScript?
What is the naming convention commonly used for variables in JavaScript?
What is the naming convention commonly used for variables in JavaScript?
Which of the following is a reserved word and cannot be used as a variable name in JavaScript?
Which of the following is a reserved word and cannot be used as a variable name in JavaScript?
What is the default value of a variable in JavaScript if it has been declared but not assigned a value?
What is the default value of a variable in JavaScript if it has been declared but not assigned a value?
Signup and view all the answers
What does assigning null to a variable represent in JavaScript?
What does assigning null to a variable represent in JavaScript?
Signup and view all the answers
Study Notes
Variable Names in JavaScript
- Variable names in JavaScript can only contain letters (a-z or A-Z), digits (0-9), and the underscore (_) character.
- The dollar sign ($) character is also allowed, but it's not commonly used.
Naming Convention for Variables in JavaScript
- The commonly used naming convention for variables in JavaScript is camelCase, where the first word is in lowercase and the subsequent words start with a capital letter.
Reserved Words in JavaScript
- Certain words like
break
,case
,catch
,continue
,debugger
,default
,delete
,do
,else
,finally
,for
,function
,get
,goto
,if
,in
,instanceof
,let
,new
,of
,on
,return
,set
,static
,switch
,throw
,try
,typeof
,var
,void
,while
, andwith
are reserved words and cannot be used as variable names in JavaScript.
Default Value of Variables in JavaScript
- If a variable is declared but not assigned a value, its default value is
undefined
.
Assigning Null to a Variable in JavaScript
- Assigning
null
to a variable in JavaScript represents the intentional absence of any object value, which is different fromundefined
.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Test your knowledge of JavaScript variable naming conventions and syntax rules in this quiz. See if you can identify correct and incorrect variable declarations, and understand the use of semi-colons and camelCase naming.