Basic MCQs of JavaScript

Basic MCQs of JavaScript 1: Which of the following methods is used to add an element to the end of an array? a) push() b) pop() ...

Basic MCQs of JavaScript

1: Which of the following methods is used to add an element to the end of an array?

  • a) push()
  • b) pop()
  • c) concat()
  • d) shift()

a) push()

2: Which of the following is used to declare a variable in JavaScript?

  • a) let
  • b) var
  • c) const
  • d) All of the above

d) All of the above

3: What is the correct way to check if a variable x is NOT equal to 5 in JavaScript?

  • a) x =! 5
  • b) x != 5
  • c) x !== 5
  • d) x <> 5

c) x !== 5

4: Which built-in method is used to convert a string to lowercase letters?

  • a) toLowerCase()
  • b) lowerCase()
  • c) convertToLower()
  • d) changeCaseToLower()

a) toLowerCase()

5: The “typeof” operator in JavaScript is used to:

  • a) Check if a variable is of type “undefined”
  • b) Determine the type of a variable
  • c) Convert a value to a string
  • d) Create a new variable

b) Determine …

6: What is the output of the following code?

console.log(2 + “3”);

  • a) 23
  • b) 5
  • c) “23”
  • d) 6

c) “23”

7: Which of the following is NOT a valid way to declare a function in JavaScript?

  • a) function myFunction() {}
  • b) var myFunction = function() {}
  • c) const myFunction = () => {}
  • d) let myFunction() {}

d) let myFunction() {}

8: The output of the following code will be:

console.log(typeof null);

  • a) object
  • b) null
  • c) undefined
  • d) number

a) object

9: The “this” keyword in JavaScript refers to:

  • a) The current function
  • b) The global object
  • c) The object that owns the executing code
  • d) The previous object that called the function

c) The object…

10: What is the result of the following expression?

“5” + 2

  • a) 7
  • b) “7”
  • c) “52”
  • d) 52

c) “52”

Advance MCQs of JavaScript

11: How can you add a comment in JavaScript?

  • a) //This is a comment
  • b) <!–This is a comment–>
  • c) This is a comment
  • d) /This is a comment/

a) //This is a comment

12: Which of the following methods is used to remove the last element from an array in JavaScript?

  • a) pop()
  • b) push()
  • c) shift()
  • d) unshift()

a) pop()

13: The “NaN” value in JavaScript stands for:

  • a) Not a Null
  • b) Not a Number
  • c) No Available Number
  • d) Null and Negative

b) Not a Number

14: What is the correct way to write a conditional statement in JavaScript?

  • a) if (x === 5) { … }
  • b) if x = 5 { … }
  • c) if x == 5 then { … }
  • d) if [x = 5] { … }

a) if (x === 5) { … }

15: Which of the following methods is used to remove the first element from an array in JavaScript?

  • a) pop()
  • b) push()
  • c) shift()
  • d) unshift()

c) shift()

16: What is the result of the following expression?

10 % 3

  • a) 1
  • b) 0
  • c) 3.33
  • d) 10

a) 1

17: Which of the following is NOT a valid JavaScript data type?

  • a) boolean
  • b) string
  • c) number
  • d) character

d) character

18: The “splice()” method in JavaScript is used for:

  • a) Sorting an array
  • b) Adding elements to an array
  • c) Removing elements from an array
  • d) Reversing an array

c) Removing elements…

19: What is the output of the following code?

console.log(2 ** 3);

  • a) 8
  • b) 6
  • c) 23
  • d) 9

a) 8

20: Which of the following is used to declare a constant variable in JavaScript?

  • a) let
  • b) var
  • c) const
  • d) final

c) const

JavaScript Online Quiz with Answers

21: What does the “=== ” operator in JavaScript check for?

  • a) Value equality
  • b) Type equality
  • c) Both value and type equality
  • d) None of the above

c) Both value…

22: The output of the following code is:

console.log(Boolean(“”));

  • a) true
  • b) false
  • c) undefined
  • d) null

b) false

23: Which of the following is used to loop through the elements of an array in JavaScript?

  • a) for loop
  • b) while loop
  • c) do-while loop
  • d) All of the above

d) All of the above

24: The “parseInt()” function in JavaScript is used to:

  • a) Convert a string to an integer
  • b) Convert a number to a string
  • c) Round a number to the nearest integer
  • d) Remove decimals from a number

a) Convert a string …

25: What is the correct way to write a JavaScript array?

  • a) [1, 2, 3, 4]
  • b) (1, 2, 3, 4)
  • c) {1, 2, 3, 4}
  • d) “1, 2, 3, 4”

a) [1, 2, 3, 4]

26: What is the result of the following expression?

“5” == 5

  • a) true
  • b) false
  • c) undefined
  • d) null

a) true

27: Which of the following is NOT a valid JavaScript comparison operator?

  • a) ==
  • b) !=
  • c) <=
  • d) ><

d) ><

28: What is the output of the following JavaScript code?

console.log(Math.floor(4.7));

  • a) 4
  • b) 5
  • c) 4.7
  • d) 5.3

a) 4

29: Which of the following is NOT a JavaScript framework or library?

  • a) React
  • b) Angular
  • c) Vue
  • d) JavaFX

d) JavaFX

30: Which of the following methods is used to convert a string to an array in JavaScript?

  • a) split()
  • b) join()
  • c) slice()
  • d) concat()

a) split()

JavaScript Online Test Preparation

31: What is the output of the following code?

console.log(10 > 9 > 8);

  • a) true
  • b) false
  • c) undefined
  • d) error

b) false

32: The “querySelector()” method in JavaScript is used to:

  • a) Select the first element that matches a specified CSS selector
  • b) Add a new CSS class to an element
  • c) Change the CSS style of an element
  • d) Remove an element from the DOM

Answer: a)

33: What is the output of the following code?

console.log(3 + 2 + “7”);

  • a) 12
  • b) 327
  • c) “57”
  • d) 7

c) “57”

34: Which of the following is used to pause the execution of JavaScript code for a specified amount of time?

  • a) setTimeout()
  • b) setInterval()
  • c) clearTimeout()
  • d) clearInterval()

a) setTimeout()

35: What does the “return” statement do in a JavaScript function?

  • a) Stops the execution of the function and returns a value
  • b) Defines a new variable within the function
  • c) Prints a message to the console
  • d) Loops through an array

a) Stops the execution..

COMMENTS

TECH$type=three$author=hide

Name

5g & 6g Technology Solved MCQs,1,Abbreviations,1,Accounting & Auditing,1,Active Voice,1,Agriculture,1,Agriculture Solved,1,Air Pollution,1,Allama Iqbal,1,Amazon Web Services AWS solved MCQs,1,Antibiotics,1,Antonyms,1,Artificial Intelligence,2,ASF,1,Assistant,6,Auditing,1,Authors,1,Banking,1,Battles,1,Battles of Islam,1,Bioinformatics,1,Biological Science,1,Biology,49,Blockchain Technology,1,Books,1,Botany,1,British History,1,Business,1,Business Administration,1,Carbohydrates,2,Carbon,1,Carbon Neutrality,1,Cell,1,Cell organelles,1,ChatGPT,1,CHEMISTRY,3,Chromosomes,2,City Names,1,Clerk,1,Code Of Criminal Procedure 1898,1,Communication Skills,1,Components of Food,1,Compounds,1,Computer,4,Computer Science,5,Constitutional Law,1,Coordination,1,Corona Virus,1,Correct Spelling,1,Cryptocurrency,1,CSS,6,CSS MPT,2,Current Affairs,6,Current affairs of Pakistan,1,Current affairs Pakistan,1,Cybersecurity,1,Database,1,DeepSeek,1,Digestion and Absorption,1,Digital Detox,1,Diseases,1,Economics,2,Ecosystem,1,Edge Computing,1,Education,2,Educational Psychology,1,Engineering,3,English,16,English Grammar,6,English Literature,1,english Litrature,1,English Precis and Composition,1,English Prepositions,1,English Synonyms,1,Entomology,1,Entrepreneurship,1,Erythropoietin,1,European History,1,Everyday,1,Everyday Science,6,Everyday Science Solved,1,Fabric,1,Factors,1,FBR,2,FBR Jobs Test,1,Fibre,1,Finance,1,Fisheries,1,Food Microbiology,1,Fossils,1,FPSC,3,FPSC Assistant Solved MCQs,1,Gender Studies,1,General Knowledge,20,General Knowledge Pakistan,1,General Science,1,Generative AI,1,Geography,1,Geology,1,GMAT Test,1,Grammar,1,GRE Test,1,Green Energy,1,Green Technology,1,Hazrat Muhammad PBUH,1,Health and Hygiene,1,Health Physical Education,1,Histology,1,History,1,IBA University,1,IELT Test,1,Immunity,1,Immunology,1,Indo-pak,1,Infectious Diseases,1,Inheritance,1,Inter provincial coordination,1,International Law,2,International Relations,2,Inventions,1,Islam,8,Islamiat,8,Islamic Banking,1,Islamic History,1,IT,4,JavaScript,1,Journalism Mass Communication,1,LDC,1,Library Information,1,Liver,1,Lower Division Clerk,1,Lysosome,1,Machine Learning,1,Management,1,Market Management,1,Mass Communication,1,Mathematics,2,Medical,5,Memory,1,Mercantile Law,1,Metabolism,1,Microbiology,1,Microbiology Solved MCQs,1,Mineral,1,Minerals,1,Ministry of Defense (MOD),3,MPT,1,Multiples,1,Municipal Officer,1,Muslim Law Jurisprudence,1,NASA,1,National,3,National Heritage and Culture,1,Neural Control,1,Neurology,1,NTS,3,Nutrition,2,Nutrition in Plants,1,Operating System,1,Others,5,Pak Studies,1,Pakistan,11,Pakistan Affairs,1,Pakistan Penal Code 1860,1,Pakistan Studies,4,PCR,1,Pedagogy,1,Pharmaceutics,1,Pharmacy,1,PHP,1,Phylum Mollusca,1,Physical Education,1,Physics,1,Plant Growth and Development,1,plant protection department,1,Plant Tissue Culture,1,Ploitical Science,1,Pollution,2,Polymerase Chain Reaction,1,Postal Clerk,2,Postman,1,PPSC,8,Principles of Inheritance and Variation,1,Proteins,1,Psychology,1,Public Administration,1,Punjab Land Revenue Act,1,Reproduction in Organisms,1,Respiration,1,Respiratory system,1,Saraiki Culture,1,SCIENCE,2,Screening test,1,Signaling,1,Sociology,1,Solid Waste Management,1,Sports,2,Structural Organization in Animals,1,Surface Area & Volume,1,TEACHING,5,Town Officer,1,Transport in Plants,1,UDC,1,Universe,2,UOS (University of Sargodha),1,Upper Division Clerk,1,URDU,9,USA History,1,Viruses,1,Vitamins,2,Water Pollution,1,Web3,1,Web3 Technology,1,World,20,World Famous,1,World-GK,1,Zoology,3,Zoology Botany,1,
ltr
item
SOLVED MCQs FOR ALL: Basic MCQs of JavaScript
Basic MCQs of JavaScript
https://blogger.googleusercontent.com/img/a/AVvXsEhKaThkGvNNvTqZ22BDoOQ2kLNkXQHMyPpyuVzV8_SoRhjh1kaCmOlzf-bss67PlcNnaWoIJQcThprERJ4cntGePWIL57bUu7SmPDCnSl9i0gUCyMHiMAFBmoOIUQoeinrSBdFgC_XpgJSD1Ytzw-C974rATvZ5qIjX3iZCxg_h1AYzAk2WqiZmKO830oQ
https://blogger.googleusercontent.com/img/a/AVvXsEhKaThkGvNNvTqZ22BDoOQ2kLNkXQHMyPpyuVzV8_SoRhjh1kaCmOlzf-bss67PlcNnaWoIJQcThprERJ4cntGePWIL57bUu7SmPDCnSl9i0gUCyMHiMAFBmoOIUQoeinrSBdFgC_XpgJSD1Ytzw-C974rATvZ5qIjX3iZCxg_h1AYzAk2WqiZmKO830oQ=s72-c
SOLVED MCQs FOR ALL
https://solvedmcqs.blogspot.com/2023/07/basic-mcqs-of-javascript.html
https://solvedmcqs.blogspot.com/
https://solvedmcqs.blogspot.com/
https://solvedmcqs.blogspot.com/2023/07/basic-mcqs-of-javascript.html
true
3555367411482497961
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content