I'm not a JavaScript newbie, but I was reading MDN page on primitive data types and it caught my attention the following line:
A primitive (primitive value, primitive data type) is data that is not an object and has no methods. In JavaScript, there are 6 primitive data types: string, number, boolean, null, undefined, symbol (new in ECMAScript 2015).
Source: https://developer.mozilla.org/en-US/docs/Glossary/Primitive
If primitives have no methods, then why is it possible to do this in JavaScript:
'HELLO WORLD'.toLowerCase() // result: hello world
Why isn't that invalid? Shouldn't that throw an "Uncaught SyntaxError: Invalid or unexpected token" just as the following statement does:
2.toString()