Hello

I'm reading David Flanagan's "JavaScript: The Definitive Guide 6th ed", which says on page 44:
There is a fundamental difference in JavaScript between primitive values (undefined, null, booleans, numbers, and strings) and objects (including arrays and functions). Primitives are immutable: there is no way to change (or “mutate”) a primitive value.
And still, the following code works:
Code:
"use strict";

var myvar = "hello, world!";
myvar = "changed!";

function myfunc(){
	console.log("Before");
	//alert(myvar);
	document.write(myvar);
	console.log("After");
}
I expected to get an error with "myvar="changed!";" but it works. Did I misunderstand what is meant with primitives being immutable?

Thank you.