CS FundamentalsVery hardProduct-company placement · Node.js interview
In npm's semantic-version ranges, which versions does ^1.4.2 allow, and which does ^0.4.2 allow?
- A. ^1.4.2: >=1.4.2 <2.0.0; ^0.4.2: >=0.4.2 <0.5.0
- B. ^1.4.2: >=1.4.2 <1.5.0; ^0.4.2: >=0.4.2 <1.0.0
- C. Both allow any later version
- D. ^1.4.2: exactly 1.4.2; ^0.4.2: exactly 0.4.2
Correct answer: A. ^1.4.2: >=1.4.2 <2.0.0; ^0.4.2: >=0.4.2 <0.5.0
The caret allows changes that do not modify the left-most non-zero digit. For 1.x that permits minor and patch updates; for 0.4.x, where minor bumps may break, it permits only patches. ~1.4.2 would allow <1.5.0.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- Two developers run npm install on the same commit a month apart and get different dependency versions, though package.json is unchanged…
- Your app depends on libraries P and Q. P needs utils >=2.0 <3.0 and Q needs utils >=1.2 <2.0. In an ecosystem that allows only one version…
- How many of these refactoring statements are correct? 1. A refactoring must not change the observable behaviour of the code. 2. A good…
- A structure chart shows a date-formatting utility called by 14 modules (high fan-in) and a controller module that calls 23 different…
- A team keeps postponing cleanup of a hard-coded module: each new feature touching it now takes three days instead of one. In the…
- A UML state machine has the transition Idle → Processing labelled 'submit [cart not empty] / validateCart()'. What do the three parts mean?