Podcast
Questions and Answers
What is the correct syntax for an if statement in JavaScript?
What is the correct syntax for an if statement in JavaScript?
When does the else block of an if...else statement execute in JavaScript?
When does the else block of an if...else statement execute in JavaScript?
What is the purpose of using else if in JavaScript conditional statements?
What is the purpose of using else if in JavaScript conditional statements?
Which JavaScript statement should be used when selecting among multiple blocks of code to be executed?
Which JavaScript statement should be used when selecting among multiple blocks of code to be executed?
Signup and view all the answers
What is the purpose of a for loop in JavaScript?
What is the purpose of a for loop in JavaScript?
Signup and view all the answers
What is hoisting in JavaScript?
What is hoisting in JavaScript?
Signup and view all the answers
What does hoisting allow in JavaScript?
What does hoisting allow in JavaScript?
Signup and view all the answers
Which keyword was introduced in ES6 to declare variables with block scope?
Which keyword was introduced in ES6 to declare variables with block scope?
Signup and view all the answers
What happens if you try to access a variable declared with let
before its declaration?
What happens if you try to access a variable declared with let
before its declaration?
Signup and view all the answers
In JavaScript, what can arrays hold as elements?
In JavaScript, what can arrays hold as elements?
Signup and view all the answers
Study Notes
Declaring and Redeclaring Variables
- JavaScript variables are declared with the
var
keyword. - Variables can be assigned values when declared or later.
- Redeclared variables do not lose their original value.
JavaScript Operators
Arithmetic Operators
- Used to perform arithmetic between variables and/or values.
- Examples:
+
,-
,*
,/
, etc.
Assignment Operators
- Used to assign values to JavaScript variables.
- Examples:
=
,+=
,-=
,*=
,/=
, etc.
Comparison Operators
- Used to determine equality or difference between variables or values.
- Examples:
==
,!=
,===
,!==
,>
,<
, etc.
Logical Operators
- Used to determine the logic between variables or values.
- Examples:
&&
,||
,!
Conditional Operator
- Used to assign a value to a variable based on a condition.
- Syntax:
variablename = condition ? value1 : value2
Linking JavaScript to a Web Document
- JavaScript can be inserted into the head section of an HTML page using the `
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Learn about declaring and redeclaring variables in JavaScript using the var keyword. Practice assigning values to variables during declaration and understand how redeclaring a variable does not make it lose its original value.