• What are the responsibilities of a javascript programmer? JavaScript programming language: information for beginners. What is JavaScript

    Javascript is a constantly evolving language, especially now that there is an annual schedule for updates to the ECMAScript specification. This makes knowing Javascript beyond jQuery increasingly important.

    Of course, in this article we will not be able to cover all the necessary knowledge. Surely, there will be points that I missed, perhaps I made a mistake, or our opinions regarding the required set of knowledge will differ.

    With these aspects in mind, let's begin...

    What is FizzBizz test

    FizzBizz is usually a small test aimed at weeding out inexperienced developers. I think you'll be surprised how many JavaScript developers don't know how to write tests like this.

    As a rule, such tests do not carry much meaning. It is aimed solely at testing the abilities of potential candidates.

    Remember, there is a very high chance that you will be asked to take a test like this in an interview.

    Example of a classic FizzBizz test:

    The options for such tests are endless. Once, during an interview, I was faced with such a test, after which I had to solve two more options.

    For (var i = 1; i<= 100; i++) { if (i % 15 == 0) { console.log("FizzBuzz"); } if (i % 3 == 0) { console.log("Fizz"); } if (i % 5 == 0) { console.log("Buzz"); } }

    Difference between == and ===

    You're probably familiar with both comparison operators. However, do you know exactly how these operators differ? Your Javascript Linter requires you to use the === operator, have you ever wondered why?

    Does not compare the types of the operands, instead it casts them to the same type. This operation has a negative reputation.

    Console.log(24 == "24"); // true

    As you can see, the string value 24 (in single quotes) has been cast to an integer type. Of course, there are situations when this is exactly what you want, but more often than not you won't want the comparison operator to manipulate data types. Comparing data using the == operator is not recommended; most javascript code style checking systems will show you this error.

    === (strict comparison) compares data types without converting them to one type, that is, the data will be compared as is. Also, since this operation does not involve type casting, it works faster. Thus, for this operator to work correctly, operators of the same type are required.

    The same example, but with the operator ===

    Console.log(24 === "24"); // false

    We get false in response, since the operands are of different types, one of them is an integer type, and the second is a string.

    How to select DOM elements without additional libraries

    Surely you are familiar with how to select elements using jQuery, but can you do the same, but without the help of this library?

    I don't just mean selecting an element with a specific ID or a set of classes, I'm talking about expressions for finding elements using jQuery.

    There are several native methods for finding elements in the DOM that are just as good as jQuery. We can also use selectors like first-child , last-child , etc.

    Let's take a look at some of these methods.

    • document.getElementById is a classic method for finding elements by their ID.
    • document.getElementsByClassName - selecting elements by className field value
    • document.querySelector is a great method that almost completely replaces jQuery's $() selector, but it's already included in Javascript. The only difference is that it only returns the first element found.
    • document.querySelectorAll - similar to the previous method, but returns an array of found elements.
    • document.getElementsByTagName - This method will help you select elements by tag name. If you need to find all div elements, then this is the method you need.

    I would also like to note that the querySelector and querySelectorAll methods can be used not only on the entire document, but also on individual elements, that is, you can make a selection within one parent element.

    See the mozilla documentation for a complete description of these methods.

    Raising variable and function declarations

    Javascript is interesting in how it handles declared variables and functions, all of which are automatically raised to the top of scope. This way you can access them before they are declared in scope (for example, functions in javascript have their own scope).

    Therefore, to make your code easier to read, make it a rule to ALWAYS declare variables at the beginning of the scope. If you specify 'use strict' at the top of the script or function, you will receive an error when accessing an undeclared variable.

    Most code style checking tools like Jshint will give you an error if you didn't use 'use strict' , so if you're trying to write good code, you won't be able to use variables before they're declared anyway. As always, if you have questions, please refer to the documentation from mozilla, there you will always find a complete and comprehensive description of your problem.

    Using Developer Tools in the Browser

    Most often, such tools are used for debugging javascript scripts, but their functionality is not limited to this. For example, you can use a breakpoint to execute your script step by step, going into each function at the same time.

    These tools provide invaluable assistance as you can fully monitor your application and find problem areas.

    By learning to use developer tools in browsers such as Chrome, Firefox, and the latest versions of Internet Explorer, you can debug your script, measure its performance, and find places where the algorithm can be improved.

    Never try to debug code blindly, always analyze it first using developer tools. Solving problems that don't exist is a waste of time.

    Console Commands

    Let's move on to the next point in studying developer tools. As a rule, they all offer a console in which you can interactively execute Javascript code.

    Surely, you are already familiar with commands such as console.log and console.error , but the functionality of the console is not limited to this.

    I would like to immediately note that not all of the commands listed will work in all browsers. I will try to mention only those that work in modern browsers. However, as an advice, I will say that before using them, try to check their functionality yourself, so as not to clutter up the code in vain.

    • console.log - used to log events. Supports formatting.
    • console.error - for logging errors in the code. I use this command when errors occur in AJAX requests and other potentially dangerous areas of code. The method is similar to the previous one, but it prints a list of stack calls.
    • console.dir(object) - displays the formatted contents of the object. As a matter of fact, this method is very useful when debugging code.
    • console.group(title) - allows you to create a group of messages in the log with the name title. This way you can group messages, for example, by the section of code where they are generated.
    • console.groupCollpased is similar to the previous command with one exception. Namely, it displays messages in a collapsed form.
    • console.groupEnd - ends a previously created group.
    • console.time(label) - allows you to track the speed of the site in milliseconds. The method is useful in catching potentially complex sections of code.
    • console.timeEnd(label) is an analogue of the groupEnd method, but it works in relation to console.time().
    • copy(string) - There is a method in the Chrome and Firefox console that allows you to copy the contents of a string to the clipboard. A very useful method, try it.

    What exactly is contained in this

    This is primarily a big source of problems for those who do not fully understand what exactly is behind this keyword. And it is very easy to make a mistake in this, since its contents depend entirely on the structure of the code.

    In traditional programming languages, this contains a reference to the current class object. But since javascript is far from tradition, in it this variable refers to the parent object of the method.

    The easiest way to understand this is to think of it as the owner or parent of the method. this always refers to the parent, except when you use the call, apply, or bind methods.

    In the following example, this refers to the window object:

    Function myFunction() ( console.log(this === window); // true ) myFunction();

    Surely you have a question, how can this be equal to window if we access it within a method? If you know the answer to this question then great, otherwise read on and I'll try to explain.

    When you declare a function this way, it is bound to the global window object. Remember when we said that this refers to the parent of the method?

    Changing the value of this to a completely new object (not window):

    Function myFunction() ( console.log(this === window); // false ) new myFunction();

    Proponents of code purity are probably shocked by this example. We're just scratching the surface of the iceberg with these examples. As you can see for yourself, the value of this is no longer equal to window .

    Why did this happen?

    The simplest explanation is that in the second example we used the new keyword, thereby creating a new scope and a new object.

    In the following example, we will create a dummy API to download data from a library from the server. We will create an API object with some methods.

    When using the word new , the script context moves from the window context to the API context.

    Var API = ( getData: function() ( console.log(this === window); // false console.log(this === API); // true ) ) ; API.getData();

    As you can see, the value of this is completely determined by the way the method is called. Since the function is called within the API object, its parent, the value of this refers to the API object.

    Remember, the value of this changes. It changes depending on how you call it, but if you use the bind method, the value of this remains the same.

    You can learn more about the this keyword in javascript in the Quirksmode article and documentation from Mozilla.

    'use strict';

    As we indicated earlier, user strict is used to apply a more strict version of the javascript language. This directive should be used in all scripts.

    By default, javascript is quite free in its syntax. It will simply skip the erroneous section of code and try to execute subsequent lines without telling you anything.

    There is a whole article on this topic in the mozilla documentation, I highly recommend you check it out.

    Different types of cycles

    You will be surprised, but I have met a huge number of developers who did not know how to use a for loop correctly and had absolutely no knowledge of other types of loops. And being able to use a loop on an array or object is a very important skill for a developer. There are no clear instructions on when and what type of cycle to use, but you should be guided in this matter. You're probably familiar with for and while, but what about the others?

    List of loops in javascript:

    • for..in
    • for..of (added in ES6)
    • forEach
    • while
    • do..while

    for loop

    An absolutely mandatory cycle that you need to know and understand. HE executes his body when condition 2 is met.

    For (condition 1; condition 2; condition 3) ( // Your code )

    Condition 1 - is fulfilled once before the start of a series of cycles. In most cases, you will initialize the loop counter here. This item can be skipped if you have completed the initialization earlier.

    Condition 2 - This condition is used to determine whether to continue the loop or not. You will probably be comparing your counter with the size of the array here. If the comparison value is true, then the loop continues. If you interrupt the loop inside with break, then this condition can be skipped.

    Condition 3 - this section is fulfilled after each iteration, as a rule, this is where you increase your counter.

    For...in loop

    The next most important type of cycle. With its help you can go through all the fields of the class.

    Let's give an example.

    Var person = ( firstName: "Dwayne", lastName: "Charrington", age: 27, starSign: "Aquarius"); // The below loop will output: // "Dwayne" // "Charrington" // 27 // "Aquarius" for (var p in person) ( if (person.hasOwnProperty(p)) ( console.log(person[ p]);

    Loop for...of

    A fairly new loop type was added in ES6. Due to its novelty, it is not supported by all browsers. But with the use of certain technologies, it can be used today.

    This loop is the exact opposite of for...in , it iterates through field values ​​and only works on data types that support iteration, which Object is not.

    Var fruits = ["orange", "apple", "squash", "pear"]; for (var fruit of fruits) ( console.log(fruit); )

    The big advantage of this type of loop is that we no longer have to create a pointer and keep track of the length of the array in order to completely traverse its elements.

    forEach loop

    Another type of cycle, which in its depth is no different from the previously listed types of cycles.

    It only works with arrays, not objects. This is beneficial because you don't have to create additional variables that end up polluting your code.\

    This is probably the most limited type of loop, but it has its own areas of application that you should know about:

    Var fruits = ["apple", "banana", "orange", "grapes", "pear", "passionfruit"]; // The three values ​​on the callback function are: // element - The element being traversed // index - The current index of the item in the array starting at 0 // array - The array being traversed (probably mostly irrelevant) fruits. forEach(function(element, index, array) ( console.log(index, element); ) );

    Sometimes you just need to iterate through all the elements of an array and maybe make some changes to them. Its behavior is similar to jQuery.each.

    One disadvantage of this type of loop is that it cannot be interrupted. If you need to create a loop according to ES5 rules, then use the Array.every method, which you can find in the mozilla documentation.

    while loop

    The while loop is similar to for , but it takes only one parameter - the condition itself, by which the loop determines whether to continue iterations or stop them.

    Although this type of cycle is considered the fastest, I believe that this point is quite controversial. I think you will not argue that this type of loop does not look neater than others, and its speed can only be explained by the simplicity of the internal logic.

    From experience, I will say that the fastest version of the while loop is a loop with a decrement counter, you decrement it by one until you reach zero (which is also debatable).

    Var i = 20; while (i--) ( console.log(i); )

    do...while loop

    This cycle is quite rare, but it is still worth getting acquainted with it in order to understand its work.

    The while loop may not complete a single iteration. That is, if you pass a false value as a condition to the loop, then not a single iteration will be executed. The do...while loop is guaranteed to perform at least one operation.

    The difference doesn't end there. The while loop processes the condition before the iteration, and the do...while loop after.

    As always, you will find a detailed description of this type of loop in the mozilla documentation.

    Basic methods and tasks

    There are basic methods in javascript that you should know about. When it comes to working with arrays and strings, javascript offers a large set of built-in methods. We will only touch on arrays and strings, leaving objects for later.

    If you are interested in methods for working with other data types, feel free to refer to the mozilla documentation. Of course, you should not know all these methods by heart; I will describe only those that I consider necessary.

    Working with Strings

    In javascript, you will most often work with string data, with the possible exception of arrays and objects. Even if you don't work with strings, or think you don't, it's still worth getting to know these methods.

    • String.replace(regexp | what to replace, what to replace with, callback) - allows you to replace part of a string; regular expressions can be used.
    • String.concat(line 1, line 2...) - concatenate several lines into one.
    • String.indexOf(value) - the method allows you to find the serial number of the character of the searched part of the string, -1 - if the string is not found
    • String.slice(startIndex, endIndex) - returns the section of string from startIndex to endIndex
    • String.split(separator, limit) - splits the string into an array by separator character, maximum length limit.
    • String.subsctr(startIndex, length) - returns the part of the string starting with startIndex with length length.
    • String.toLowerCase - converts all characters in a string to lower case
    • String.toUpperCase - convert all characters of the string to upper case
    • String.trim - removes spaces from the beginning and end of a string

    Working with Arrays

    You will encounter arrays very often. They have proven themselves to be a great way to store data. These methods are definitely worth knowing for any javascript developer, you shouldn't search for them on Google.

    • Array.pop - Returns the last element and removes it from the array.
    • Array.shift - Returns the first element and removes it from the array.
    • Array.push(val1, val2) - adds one or more values ​​to the end of the array. Returns the new length of the array.
    • Array.reverse - reverses the order of array elements.
    • Array.sort([Compare function]) - allows you to sort an array using your own function.
    • Array.join(separator) - Returns a string consisting of array elements separated by the separator character (comma by default).
    • Array.indexOf(value) - returns the index of the element in the array, -1 if the element is not found.

    This is not a complete list of methods for working with arrays. You can find others in the mozilla documentation. Since ES6, some very interesting methods have been added.

    Difference between call and apply

    Developers confuse these two methods quite often. You can often do without them, but they help you call methods and change the this value at runtime.

    The difference between them is very small, but it exists. When using the call method, you can specify an infinite number of arguments, separated by commas.

    With the apply method, you can pass arguments as an array and change the value of this .

    If you just need to pass an array as arguments to a method, then since ES6 a spread operator has been added. It does not allow the value of this to be changed. You can get acquainted with it, as always, in the official documentation from mozilla.

    Example call:

    Function myFunc() ( console.log(arguments); ) myFunc.call(this, 1, 2, 3, 4, 5);

    apply example:

    Function myFunc() ( console.log(arguments); ) myFunc.call(null, );

    Introduction to libraries and frameworks

    Today, the most notable representatives of javascript frameworks are AngularJS, React.js and Ember. Of course there are a number of others.

    As web applications become larger and larger, these libraries make working with them easier. It is worth understanding that now knowing jQuery alone is clearly not enough. Most vacancies list knowledge of additional javascript libraries as a basic requirement.

    Node.js

    Without a doubt, Node.js has a strong position. Almost any front-end tool is built on node.js and uses npm (node ​​package manager), if you are unfamiliar with it, I strongly advise you to correct this omission. Since node.js uses javascript, learning it is not particularly difficult for those who are already familiar with this language. You will spend more time configuring node packages than writing the code itself.

    Personally, I think every developer in 2015 should be familiar with Node. I'm not talking about deep knowledge, it is enough to be able to apply it for server development, prototyping, testing, etc.

    There is a fork of node.js called IO.js, today they are almost identical, and in the end you are just writing in Javascript except for small differences.

    Testing

    Once upon a time, we didn’t test javascript code at all, because we didn’t think it was necessary. But scripts are getting bigger and bigger thanks to AngularJS and Node.js.

    Javascript is evolving, and the volume of scripts is increasing and testing is becoming vital. If you don't test your code, then you're doing it wrong. My favorite tester is Karma. There are others, but this one has proven to be the best when working with AngularJS. And if it's good for AngularJS, then it's good for me.

    Tools

    Being a JavaScript developer in 2015 means not only excellent knowledge of the language, but also a large number of tools for working with it.

    Sometimes the tools include the browser we use itself. And sometimes you have to turn to third-party tools to get a more in-depth analysis of the situation.

    Here's a set of tools to keep in mind: Gulp, Webpack, and BabelJS. There are many more tools out there, but tools like Gulp and Grunt greatly help you in developing and managing javascript applications.

    Gone are the days when you simply downloaded a javascript file and added it to your page. We now use NPM or Bower package managers.

    We combine and minimize scripts, test them, which helps organize the project structure.

    javascript tools go hand in hand when developing isomorphic Javascript (code used on both the client and server side). ECMAScript 6, aka ES6, aka ESNext

    Browsers have yet to implement much of the functionality of ECMAScript 6. But today you can use the new features from ES6 using javascript compilers. Get to know new APIs and methods: strings, arrays and other methods like WeakMaps, Symbols and Classes. You should always be aware of upcoming changes.

    Conclusion

    I can tell you a lot more. Judging by the size of this article, you can imagine how much a JavaScript developer needs to know. We have only touched the tip of the iceberg. Please do not think that this article should be taken as a developer's guide. This is just my personal view of the problem.

    Adapted translation of the article “Full-Stack JavaScript in Six Weeks: A Curriculum Guide”

    Web development is one of the simplest and therefore popular areas among novice programmers. Any text editor and browser is enough to work; there is no need to study algorithms at an advanced level, the result of each stage of writing a program is clear - in general, there are many advantages. A key skill in the context of web development is knowledge of JavaScript.

    Nowadays JavaScript is developing very quickly, and therefore it is easy to get confused when learning the language. We offer you a well-structured curriculum that covers all the essential aspects of JavaScript and related technologies.

    Why JavaScript?

    It is worth noting the openness of the language - companies that usually compete with each other are collaborating to develop JavaScript. The language is very flexible and will suit supporters of both object-oriented and functional approaches. A huge number of libraries and frameworks make it easy to solve any type of problem, and the Node.js server platform makes it possible to use the language not only in the browser, but also in the console. You can even write desktop and mobile applications: the former using the Electron framework, and the latter using NativeScript or React Native.

    Basics

    First you need to learn the basic concepts of JavaScript, web development and programming in general:

    • object-oriented JS - constructors and factories, inheritance;
    • functional JS - higher order functions, closures, recursion;
    • Jasmine test specifications;
    • basics of HTML, CSS and jQuery.

    Git

    Git is an essential tool for developers, so get started with it as early as possible. Here are the basic skills you should have:

    • creating and moving files in directories;
    • initialization and commits in Git;
    • setting up repositories in GitHub.

    Algorithms and data structures

    Next, it's worth learning about algorithms (in particular, the concept of algorithmic complexity), as well as basic data structures: linked lists, queues, stacks, binary search trees, and hash tables. This will help you.

    Backend

    Node.js

    10 years ago JavaScript could only be used for front-end development. Now, thanks to Node.js, the matter is not limited to one “front”. Node is simply an environment for running JS code on the server side, so you won't have to learn any new syntax, but you will need to import and export files, modularize code, and use the npm package manager.

    Servers, HTTP, Express.js

    After learning Node, it's worth continuing your acquaintance with backend development and understanding servers and routing. You can start with ports and protocols with an emphasis on HTTP, and then move on to Express, a Node library for processing requests.

    Asynchronous JavaScript

    Databases, schemas, models and ORMs

    Databases are one of the most important elements of web development. If your application needs to load or store any data that is not lost when the page is refreshed, you will have to use a database. You need to learn to distinguish between relational and non-relational databases and understand the types of relationships. Then get to know different people. The ability to work with ORM will also not be superfluous.

    Frontend

    HTML and CSS

    HTML and CSS are the foundation of any web developer. You don't have to know them perfectly, but you should understand them. You can also explore a popular library (for example, Bootstrap) and a CSS preprocessor like Sass - it will help make CSS look like regular code. To simplify working with HTML, you can choose one of the popular template engines, for example, pug.

    jQuery and DOM manipulation

    Once you've created the look and feel of your page using HTML and CSS, you'll also use jQuery to manipulate the DOM. Many people think that jQuery is useless and will soon be replaced by Angular and React, but it is insanely popular and therefore worth knowing. In addition, one day you will find yourself in a situation where it will be inconvenient for you to hammer nails with a React microscope, and then lightweight jQuery will come to your aid.

    Chrome Developer Tools

    It would be unforgivable to neglect Chrome tools, which provide a huge number of possibilities. With them you can examine DOM elements, debug via the console, trace routes, and much more. We describe several handy features of the Chrome console that will make routine tasks easier.

    AJAX

    If you want your application to not reload pages after every database operation, you'll definitely need AJAX - it sends background asynchronous HTTP requests, the responses to which only update part of the display. You can work with AJAX through jQuery using the .ajax method.

    Programming is not just a way to earn big money and is not even entirely mental work. This is an opportunity to understand what the world around us consists of, decompose it into small particles, and then reassemble it, guided by our own logic and knowledge.

    Programming languages ​​are just a tool with which a person builds rules in created systems.

    The Internet presents a wealth of opportunities that bright and enterprising minds are seizing upon. Of course, web development also has its own tools for bringing ideas to life. One of them is the JavaScript programming language, which will be discussed in this article:

    General information

    Many people, even those who have nothing to do with the IT field, have heard the word Java. A revolutionary platform-independent language in which applications for mobile systems are actively written. It was developed by the promising company Sun, which then came under the wing of Oracle. But neither company has anything to do with JavaScript:

    All that was required from Sun was permission to use part of the name. Surprisingly, JavaScript is not owned by any company at all.

    When writing web applications, JavaScript programming is used most often. If we briefly list the key features of this language, we should highlight the following:

    • Object orientation. Program execution represents the interaction of objects;
    • Data type conversion is carried out automatically;
    • Functions are objects of the base class. This feature makes JavaScript similar to many functional programming languages ​​such as Lisp and Haskell;
    • Automatic memory clearing. So-called garbage collection makes JavaScript similar to C# or Java.

    If we talk about the essence of using JavaScript, then this language allows you to “revive” motionless website pages using code that can be executed ( so-called scripts). That is, we can draw an analogy with cartoons, where html and css are the drawn characters, and JavaScript is what makes them move.

    If we talk about JavaScript syntax, then it has the following features:

    • Register is important. Functions called func() and Func() are completely different;
    • Operators must be followed by a semicolon;
    • Built-in objects and operations;
    • Spaces are not counted. You can use as many indentations as you like, as well as line breaks, to format your code.

    The simplest JavaScript code looks like this:

    Scope of application

    In order to understand why JavaScript is needed and how necessary it is to learn it, we should highlight some areas in which this programming language is used.

    • Web application development. Do you want to install a simple counter, organize data transfer between forms, or place a game on your website? Then JavaScript will be a faithful assistant in this matter;
    • "Active participation" in AJAX. This technology has made it possible to significantly speed up the operation of applications by exchanging data with the server in the “background” mode:
    • Operating systems. Some people may not have known, but Windows, Linux and Mac have their own browser competitors, the lion's share of which is written in JavaScript;
    • Mobile applications;
    • Field of study. Any programming specialty at a university includes the study of JavaScript to one extent or another. This is due to the fact that the language was originally developed for not very strong programmers. JavaScript lessons are logically woven into the basic HTML course, so learning is quite simple.

    Advantages and Disadvantages

    Don’t think that JavaScript is some kind of panacea for all problems, and every programmer uses this language with a smile on his face. Everything in the world has its positive and negative sides. First, let's note the shortcomings.

    • The need to provide cross-browser compatibility. Since JavaScript acts as an Internet technology, you have to put up with the rules that the World Wide Web sets. The code must run correctly in all, or at least the most popular, browsers;
    • The inheritance system in a language causes difficulties in understanding what is happening. JavaScript implements prototype-based inheritance. People who have studied other object-oriented programming languages ​​are accustomed to the familiar " child class inherits parent class" But in JavaScript, such things are directly handled by objects, and this is beyond your comprehension;
    • There is no standard library. JavaScript doesn't provide any capabilities for working with files, I/O streams, or other useful things;
    • The syntax in general makes it difficult to understand. The beauty of the code is clearly not the strong point of JavaScript, but the main rule of programmers is observed: “ Works? Don't touch!».

    Now it is worth noting some advantages

    • JavaScript provides a large number of capabilities for solving a wide variety of problems. The flexibility of the language allows the use of many programming patterns in relation to specific conditions. The inventive mind will have a real pleasure;
    • The popularity of JavaScript opens up a considerable number of ready-made libraries for the programmer, which can significantly simplify the writing of code and level out syntax imperfections;
    • Application in many areas. The wide capabilities of JavaScript give programmers a chance to try themselves as a developer of a wide variety of applications, and this, of course, fuels interest in professional activities.

    You shouldn’t pay attention to the fact that there were more minuses than pluses. JavaScript is firmly entrenched in its niche, and no amount of criticism will knock it out of there at the moment.

    For those who want to study

    A difficult and long path lies ahead for those who decide to thoroughly study JavaScript. For beginners, there are basic recommendations, following which you can significantly simplify your learning.

    • First of all, HTML. You can't start doing anything for the Internet without the basics. Cascading Style Sheets (CSS) will also come in very handy;
    • Use new literature. Programming is not physics, the laws of which are unbreakable, and new textbooks are stripped-down old ones. IT technologies are constantly evolving, and useful updates should not be neglected;
    • Try to write all sections of the program yourself. If something doesn’t work out at all, you can borrow someone else’s code, but only after first understanding each line for yourself;
    • Debugging is your best friend. Finding errors quickly is one of the most important aspects of programming;
    • Don't ignore formatting rules. Of course, the code will not become better or worse due to different numbers of indentations and spaces, but ease of reading and understanding by the programmer is also an important point. The code below? very difficult to perceive, especially if you are not him
    • Variable names must have lexical meaning. In the process of writing simple programs, this does not seem important at all, but when the number of lines of code exceeds a thousand, all the devils break their legs;