Learning Python & JavaScript?
โ Data Science
โ AI/ML
โ Web Development
Yes, it opens the door
to an exciting world!!!
Wanna join? Let's start.
Thoughts behind this thread
โฌ Python and JavaScript are undoubtedly the 2 most dominating languages.
โฌ Having knowledge of both would make an exciting future. You can choose various career options.
โฌ Through this (series of) thread(s), we will learn both side-by-side.
Topics for today
โ Variables
โ Data Types
โ Operators
โ Variables
โ Variable Naming
โ Variable Declaration
โ Variable Assignment
โ.โ Variable Naming
โฌ Python and JavaScript are almost similar in variable naming conventions except that JavaScript allows $ in variable names.
โฌ Python has a convention of using snake_case while JavaScript prefers camelCase naming.
โ.โ Variable Declaration
โฌ Python doesn't have any syntax to declare a variable while JavaScript has 3 keywords.
โฌ Type Declaration: Python introduced it in v3.5, but doesn't enforce it. JavaScript doesn't have any.
โฌ Both allow changing the variable type dynamically.
โ.โ Variable Assignment
Both Python and JavaScript have multiple syntaxes for assigning values to a variable.
โ Data Types
โ Built-In Data Types
โ Finding Type
โ Checking Instance Type
โ Type Casting
โ.โ Built-In Data Types
โฌ Both Python and JavaScript provide some common data types.
โฌ Each has its own set of unique featured data types.
โ.โ Finding Type
โฌ As both Python and JavaScript are dynamically typed, finding the type of a variable at runtime is a common practice.
Both provide a way to do this.
โ.โ Checking Instance Type
โฌ On some occasions, we need to check if a variable is of a particular type or not.
Both Python and JavaScript have options to do this.
โ.โ Type Casting
โฌ Data sometimes come in different formats and need to be converted to appropriate types at run-time.
Both Python and JavaScript support typecasting.
โ Operators
โ Arithmetic Operators
โ Comparison Operators
โ Logical Operators
โ Bitwise Operators
โ Assignment Operators
โ
Ternary Operator
โ Membership Operators
โ Type Checking Operators
โ Operator Overloading
โ.โ Arithmetic Operators
โ.โ Comparison Operators
โ.โ Logical Operators
โ.โ Bitwise Operators
โ.โ Assignment Operators
โ.โ
Ternary Operator
โฌ JavaScript has a ternary operator ?:
โฅ x > 5 ? 2 : 4
โฌ Though Python doesn't have any such operator, it has similar functionality.
โฅ 2 if x > 5 else 4
โ.โ Membership Operators
โฌ Python provides 2 membership operators (in, not in) that check whether an element exists in a sequence (list, tuple etc).
โฌ JavaScript has an 'in' operator which is used inside for..in loop and, for object property checks.
โ.โ Type Checking Operators
โฌ JavaScript provides 2 type checking operators (typeof and instanceof). It's discussed in โ.โ & โ.โ.
โฌ Python doesn't have any equivalent operators. But it provides 2 functions to do these. type() and isinstance()
โ.โ Operator Overloading
โฌ Python allows doing operator overloading. Python doesnโt do type conversion during evaluation.
โฌ JavaScript doesnโt have support for operator overloading. It auto converts the operands to the required type during evaluation.
Disclaimer
โฌ I have tried to show a way of learning multiple languages at the same time by comparing their syntaxes.
โฌ This thread may not contain all the information in detail.
โฌ These illustrations are part of my series "PJSython".
Hey
I am a Tech Educator and, Mentor from India
I am sharing Tutorials, Tips, Techniques, Infographics, Cheat Sheets, Practice Questions, Project Ideas and Roadmaps on Web Development, DSA and, Databases.
To never miss anything, Follow Me