JavaScript Basic Programs for Beginners
JavaScript Basic Programs for Beginners - Important Points
| 1. | What is the correct syntax for declaring a JavaScript variable? |
|---|
A. var x;
B. x = var;
C. variable x;
D. x = variable;
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The correct syntax for declaring a JavaScript variable is "var variableName;"
| 2. | What is the output of the following program? console.log(3 + 4 + "5"); |
|---|
A. 12
B. 75
C. 345
D. 7+5
View Answer Discuss Work SpaceAnswer: option b
Explanation:
| 3. | Which of the following is NOT a valid way to comment in JavaScript? |
|---|
A. // This is a comment
B. /* This is a comment /
D. # This is a comment
View Answer Discuss Work SpaceAnswer: option d
Explanation:
| 4. | What is the output of the following program? console.log(typeof "hello"); |
|---|
A. number
B. string
C. boolean
D. undefined
View Answer Discuss Work SpaceAnswer: option b
Explanation:
| 5. | Which of the following is the correct way to create a function in JavaScript? |
|---|
A. function myFunction() {}
B. var myFunction = function() {};
C. myFunction = function() {};
D. All of the above are correct.
View Answer Discuss Work SpaceAnswer: option d
Explanation: