1D0-735 CIW JavaScript Specialist Practice Questions
Prepare for 1D0-735 with more than an answer.
- Exam fee
- $175 USD
- Level
- Specialist
- Valid for
- 3 years (effective October 1, 2024)
Domains covered on the exam 4
- Essential JavaScript Principles and Practices25%
- Intermediate JavaScript Programming Techniques35%
- Applied JavaScript21%
- JavaScript Technology Extensions19%
- 1
True or False: In JavaScript, declaring a variable with
varinside a block (e.g., inside anifstatement) limits its scope to that block.Show answer details
Correct answer: B
varis function-scoped, not block-scoped. If declared inside anifblock, it is still accessible outside that block but within the containing function (or globally if not in a function).letandconstare block-scoped. - 2
When using the
typeofoperator on a variable containing the valuenull, what string is returned?Show answer details
Correct answer: B
This is a historical bug in JavaScript.
typeof nullreturns "object", even thoughnullis a primitive value. It is important to check for null explicitly (e.g.,value === null) rather than relying ontypeof. - 3
Which JavaScript feature allows a function to access variables from an outer function that has already returned?
Show answer details
Correct answer: D
A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). This gives you access to an outer function's scope from an inner function, even after the outer function has finished executing.
- 4
A developer is refactoring a legacy JavaScript application to use modern ES6 syntax. The original code uses
varfor variable declaration inside aforloop, causing scope leakage. Which variable declaration keyword should be used to ensure the loop counter is block-scoped and not accessible outside the loop?Show answer details
Correct answer: D
The
letkeyword declares a block-scoped local variable. Usingletin aforloop ensures that the variable is only available within the loop block.varis function-scoped, andconstcannot be used for a loop counter that needs to be incremented. - 5
You are writing a function that processes user input. The input is received as a string '42', but you need to perform strict mathematical addition with another number, not concatenation. Which operator or function is best suited to convert this string to a number while preserving decimal precision if present?
Show answer details
Correct answer: D
parseFloat()parses a string argument and returns a floating-point number. UnlikeparseInt(), which truncates decimals,parseFloat()preserves them, making it the best choice for general numeric conversion where precision matters. - 6
Analyze the following code snippet. What will be the value of
resultafter execution?var x = 10; var y = '5'; var result = (x > 5) && (y === 5) ? 'Pass' : 'Fail';Show answer details
Correct answer: B
The expression evaluates as follows:
(x > 5)is true.(y === 5)uses strict equality. Sinceyis a string '5' and 5 is a number, this is false.true && falseresults infalse. The ternary operator returns the second value, 'Fail'.
