CRT-600 practice question 24 of 30
Refer to the code below: function changeValue(param) { Param =5; } Let a =10; Let b =5; changeValue(b); Const result = a+ “ - ”+ b; What is the value of result when code executes?
Full set: 223 questionsIn JavaScript, primitive data types like numbers are passed to functions by value. When changeValue(b) is called, a copy of the value of b (which is 5) is passed as the param argument. The function then attempts to assign 5 to a variable named Param. Due to JavaScript's case-sensitivity, Param is a different variable from the parameter param. Therefore, the assignment inside the function does not affect the original variable b in the outer scope. The value of b remains 5. The final expression concatenates a (10), the string " - ", and b (5), resulting in the string "10 - 5".
A. 10 -10: This is incorrect because the variable b is never reassigned to 10. The function call does not modify its value.
B. 5 - 5: This is incorrect because the variable a is initialized to 10 and is never modified.
C. 5 - 10: This is incorrect as neither a nor b are changed to these values.
1. Mozilla Developer Network (MDN) Web Docs
Functions: "Primitive parameters (such as a number) are passed to functions by value; the value is passed to the function
but if the function changes the value of the parameter
this change is not reflected globally or in the calling function." (See the section on "Passing parameters").
2. Mozilla Developer Network (MDN) Web Docs
Lexical grammar: "JavaScript is a case-sensitive language. This means that language keywords
variables
function names
and other identifiers must always be typed with a consistent capitalization of letters." (See the section on "Case sensitivity").
3. Salesforce Lightning Web Components Developer Guide
JavaScript Considerations: The guide specifies adherence to modern JavaScript (ECMAScript). Core principles like pass-by-value for primitives and case-sensitivity are fundamental to the JavaScript used in Lightning Web Components
which is a key topic in CRT-600. The documentation consistently relies on these standard language features.
Keep practicing
Take the free CRT-600 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other CRT-600 practice questions
- Question 2A developer has the function, shown below, that is called when a page loads. function onl…
- Question 3A developer needs to test this function: 01 const sum3 = (arr) => ( 02 if (!arr.length) r…
- Question 4Refer to the code below: Const resolveAfterMilliseconds = (ms) => Promise.resolve ( setTi…
- Question 10Refer to the following code block: class Animal{ constructor(name){ this.name = name; } m…
- Question 11A developer needs to debug a Node.js web server because a runtime error keeps occurring a…
- Question 12Refer to the string below: const str = 'Salesforce'; Which two statements result in the w…
