JavaScript (JS) Python and Java-js notes

Source: Internet
Author: User

I don't know much about Java, C ++ is a little better, and python is familiar. I just started to look at JavaScript.

Two major keywords of JS: function and VaR

The type is not the main type in JS. Similar to Python, there is no explicit type definition. Variables in Python are used as needed. It is best to use VaR to define the type in Js.

Functions in JS are similar to those in Python. They are all objects and all have object attributes, but JavaScript has prototype and Python has _ dict __.

Javascript is inherited from Java. The syntax is similar to Java. It is similar to C ++, and both use {} to represent statement blocks; to indicate the end of the statement (none; the end is automatically added by the carriage return, which is significantly different from Java). >>> is also used to represent the unsigned right shift. It should be said that expressions, syntax structures, and operators are basically the same as Java and C ++.

JS does not have the concept of classes. Python, Java, and C ++ all have classes. JS simulates classes through prototype and returns a class through function, which is similar to Python meta.

JS objects can be initialized through a dictionary similar to Python. The dictionary key is used as the attribute and value as the attribute value. This is similar to Python dict, this should be the closest thing to the bottom layer of Python and Js.

JS Lambda functions are implemented through F = function (x) {return X;}, while Python Lambda is implemented directly through F = Lambda X: X. All have the anonymous declarative function.

The attributes of objects in JS can be processed through the for var I in object. Similar to Python's for I in dict. Key (), they are all traversal of an object.

The with statement is also available in JS, And the with statement is introduced in python26. However, the with statement function in JS still has some defects.

 

Consider JS function objects or JS objects as Python dict, which is easier to understand.

The array of JS is similar to that of Python. the string of js also has the join and split methods, and the obtained results are similar. Of course, slice functions are needed to call slice functions because slice operations are not as elegant as Python.

It can be considered that JS is a language between Java and Python and has a Java syntax structure and Python script.

With Java extensions, you can do python.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.