JavaScript Why are some literals, actually objects, while others are just non-object literals?

Assume that I have two literals: false and 1. If I invoke function toString() on both of them, I get:

false.toString() // false
1.toString()     // Uncaught SyntaxError: Unexpected token ILLEGAL

What does error happen in the second case and does not occur in the first one?

Answer:1

Consider the following code that contains a simplified implementation of Bluebird's Promise.settle: var a = Promise.reject('a'); var b = Promise.resolve('b'); var c = Promise.resolve('c'); var ...

Consider the following code that contains a simplified implementation of Bluebird's Promise.settle: var a = Promise.reject('a'); var b = Promise.resolve('b'); var c = Promise.resolve('c'); var ...

Is it possible to use CSS to highlight the section that has been linked to? If not can I get the #link in JavaScript some how? IE var section = $(window).link(); Thanks for your time

Is it possible to use CSS to highlight the section that has been linked to? If not can I get the #link in JavaScript some how? IE var section = $(window).link(); Thanks for your time

I am currently switching the menu of my site from pure JavaScript to jQuery. My menu has a rollout / rollin effect. The menu has an outer wrapper which has an onmouseout event set. If this fires, the ...

I am currently switching the menu of my site from pure JavaScript to jQuery. My menu has a rollout / rollin effect. The menu has an outer wrapper which has an onmouseout event set. If this fires, the ...

I need to call a js function everytime a key is pressed in a textbox: <html> <script> function checkValidity() { alert("Checking..."); } </script>...

I need to call a js function everytime a key is pressed in a textbox: <html> <script> function checkValidity() { alert("Checking..."); } </script>...