Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scripting Language and Compiled Language

I have two questions:

  1. How does Jquery/ MooTools extend the syntax of Javascript? I mean why can you just have new syntax for Jquery and MooTools that does not exist in Javascript?
  2. Since MooTools allows user to have class, inheritances. Interpreted language like this is getting closer to compiled language. Will they eventually replace Java (which runs on JVM)? Or are there specific aspects of Java that extension to Javascript will never achieve?

It may be foolish questions but I really want some keywords to explain them.

Thanks

like image 948
Codier Avatar asked Dec 09 '25 22:12

Codier


2 Answers

One way that JQuery gives the impression of redefining the language is with the $ operator. What may not be clear however is that $ is just a function declared at window (global) scope, since $ is a valid variable name in JavaScript:

From the source:

jQuery = window.jQuery = window.$ = function( selector, context ) {
    // The jQuery object is actually just the init constructor 'enhanced'
    return new jQuery.fn.init( selector, context );
},
like image 169
Jim Blackler Avatar answered Dec 11 '25 10:12

Jim Blackler


They are not extending the syntax of javascript per say. They still have to abide by all the grammar rules of javascript.

like image 35
Mike Park Avatar answered Dec 11 '25 10:12

Mike Park



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!