I have always wondered why Douglas Crockford keeps comparing JavaScript to Scheme. Yes JS was intended to be Scheme by its designer; but besides the first class function support and the lexical scoping (broken), what features does JS have in common with Scheme that makes it "Lisp in C's Clothing"?
What must be done in order to implement Lexical Scoping? Explanation: In order to implement lexical scoping, the internal state of a JavaScript function object must include not only the code of the function but also a reference to the current scope chain.
What is Lexical Scope in JavaScript? Lexical scope is the definition area of an expression. In other words, an item's lexical scope is the place in which the item got created.
Lexical scoping in JavaScriptJavaScript uses lexical scoping to resolve the variable names when a function is created inside another function. It determines the function's parent scope by looking at where the function was created instead of where it was invoked.
They recruited Eich in 1995, because they wanted him to create a programming language for that web browser. The lure for him was that he would be able to base the language on Scheme (a Lisp dialect). Scheme's influence led to JavaScript having closures.
Another thing that comes to mind is the pervasive use of a single ubiquitous data structure throughout the language and the libraries: cons lists in the case of Scheme, maps (called objects) in the case of ECMAScript.
Then there is not just the fact that ECMAScript has first-class procedures, but that those procedures are the only abstraction mechanism. (Or more precisely encapsulation mechanism.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With