- The "+" Symbol can have many uses, for example it may be used for Addition and Concatenation.While coding, it is possible to ignore whether a number is written as a string or not, which eventually leads to similarities, as a result, you cannot see the desired result.In fact, programmers may sometimes forget that the data which they have entered may be evaluated as a string, not a number, which can cause the data to join each other, as a result, no collective operations will be carried out. This mistake is very common, so that it is necessary to be careful in entering different data , so when needed, numbers are entered in strings, and otherwise they are entered numerically, now consider the following example for a better understanding. If you write out the code: var x = 10 + "7"; it goes up to "107,"As you can see, the numbers 7 and 10 are only joined together, and because 7 is written as a string, the two are not added together.- Confusing the assignment (=) and equality (==, ===) operators , each of these items need to be used in their proper place and have a different meaning, if you as a programmer, do not know where to use each of them, in the end you cannot do the right programming .When you want to compare two data, you need to use (==, ===) operators, the difference between the two is that three equals can make more accurate comparisons while two equals can perform a loose comparison in which only values are compared and the datatype is no longer checked and compared, now consider the following example in this regard for a better understanding.
const number = "3";
console.log (number == 3);
// true
console.log (number === 3);
// false
In this example, the variable number was assigned a string value of 1, it returns true when compared with 1 (of number type) using double equals because both values are 1, but when compared using triple equals, it returns false because each value has a different data type.One of the inevitable mistakes that can occur is memory leaks, which you can prevent by being aware of the issue and the factors that cause it to take place, now note the following code:
var theThing = null;
var replaceThing = function () {
var priorThing = theThing; // hold on to the prior thing
var unused = function () {
// 'unused' is the only place where 'priorThing' is referenced,
// but 'unused' never gets invoked
if (priorThing) {
console.log ("hi");
}
};
theThing =
longStr: new Array (1000000) .join ('*'), // create a 1MB object
someMethod: function () {
console.log (someMessage);
}
};
};
setInterval (replaceThing, 1000); // invoke `replaceThing 'once every second
In order to understand everything better, you first need to know how things are working in JavaScript under the hood, the typical way that closures are implemented is that every function object has a link to a dictionary-style object representing its lexical scope, in a case that both functions defined inside replaceThing actually used priorThing, it would be important that they both get the same object, even if priorThing gets assigned to over and over, so both functions share the same lexical environment, but as soon as a variable is used by any closure, it ends up in the lexical environment shared by all closures in that scope, and that little nuance is what leads to this gnarly memory leak, in addition to this, there are other things that may eventually cause memory leaks that you need to be aware of in order to control them.- Another mistake that may be made by various programmers , especially beginner ones, is that they do not do any planning and research for coding and rush into the coding step, which in the end make them write the code without a plan which can cause many mistakes to occur.Before programmers start coding, it is necessary to carefully examine all the available items and check what input they need to have for the outputs which they are targeting, and then enter the coding stage, so that there is no need to rush.The steps that a programmer needs to take from the beginning include Writing, Validate, and Modified, and doing all the steps, respectively, can reduce the number of mistakes that a programmer may make while programming .
Read more on:https://www.dotnek.com/Blog/Web/the-common-mistakes-that-programmers-make-whe
link:https://dotnek.mystrikingly.com/
Related link:is https secure
:: برچسبها:
dotnek ,
seo ,
site ,
:: بازدید از این مطلب : 96
|
امتیاز مطلب : 0
|
تعداد امتیازدهندگان : 0
|
مجموع امتیاز : 0