Considering that Javascript is at first, only a standard, how could this make sense to write Javascript in Javascript itself?!
Original quote is "Any application that can be written in Javascript will eventually be written in Javascript."
It is a quote from Jeffery Atwood, the co-founder of stackoverflow. blog.codinghorror.com/the-principle-of-least-power
Which in turn is based on the rule of least power, which says it is better to use the least powerful tool for the job.
Basically Javascript (at the time 2007, it's probably not most powerful language), and also because of its continue rise in popularity and ubiquitous, there is momentum to write more and more stuff in Javascript.
As he predicted, Javascript what used to be a Front End thing only, with Node.js in 2009, it become gradually become used for backend widely. Now become used more and more for things it was never original designed for.
Yes, you can write a compiler/interpreter for Javascript in Javascript. There is nothing wrong with that.
This might be referring to two things, possibly.
The idea that the language could be used to write a parser that could parse itself.
That a newer version of JavaScript could be transpiled to an older version of JavaScript, again, using JavaScript. (Like Babel.)
I haven't heard anyone say this, but I would guess if they said it, they are referring to #1.
Edit: To answer ahead of time - the purpose of this is less about actually doing it, and more about explaining what the language is capable of doing. JavaScript is capable of a lot of stuff. There's probably a more useful descriptor of "language that can implement lexing", but that's beyond the scope of my answer, and apparently beyond the scope of my quick Googling as well. Someone else on here will know what it is.
Todd
Software Security TechLead
Let's not get too complicated here - this simply means that JavaScript is a Turing Complete language. All Turing Complete languages can be used to create any computer program in theory at least.
The JavaScript engine itself is a program just like any other engine, compiler, interpreter, operating system, etc...
Thus, the JavaScript engine could be written in JavaScript itself.
I want to stop everyone here and mention a major point of stupidity in how us developers converse with one another - we often say things like "Python is written in C." Not only is that really not true, but it makes us sound like 4 year olds... The language itself is a syntax which is written by humans to express ideas to the interpreter or engine.
Python is not written in C. The Python interpreter is written in C. Likewise, JavaScript wouldn't be written in JavaScript, the JavaScript Engine/interpreter could be implemented in JavaScript.
However, in actual practice, a base JavaScript engine wouldn't generally be written in the same language because an engine would first need to be created for the language to interpret itself and thus that original engine must be written in another language.
This sound super cool but it's just hype because any language can be written in itself as long as it's Turing Complete, not just JavaScript.
In fact, as I've mentioned elsewhere here on HashNode, a man named Christopher Domas at Battele Institute showed that you can write any program at all in only mov instructions on the CPU, so therefore you could even write JavaScript by doing absolutely nothing else except assigning variables to other variables...
Now, that's a trip. :)