Read each JavaScript program and choose what it prints. Every program was run on Node.js as a normal (non-strict) script unless it says "use strict", so the answers are the real output.
Question 11Medium
What does the following JavaScript code print (console output, as in Node.js)?
main.js
const s = "JavaScript";
console.log(s.includes("script"), s.includes("Script", 4), s.includes("Script", 5));
Atrue true false
Bfalse true true
Cfalse false false
Dfalse true false
Correct Answer: Option D
includes is case-sensitive. "Script" starts at index 4, so a search from 4 finds it and a search from 5 does not.
Default sort compares character by character ("1" before "9"). The numeric option compares the digit runs as numbers: 9 < 10 < 100, and "9a" sorts right after "9".
We use Google Analytics cookies to see how LearnFrenzy is used and make it better, and Google AdSense to keep it free.
No analytics or ad cookies are set until you accept. Privacy Policy
·