Previously, there was data of a specific type and it was interesting to process them in order to obtain a result. The dominance of “atypical ideas in the field of description” came unexpectedly, but naturally. A preliminary declaration of a variable has ceased to be mandatory, and an indication of its type has completely lost all meaning, at least before the operation in which it takes part.
The programmer untied his hands: it is not necessary to announce something at the beginning. Often, only at the time of use will there be certainty what to take, what to do and how. As for types, they themselves “became values”, that is, they became data, on which something also depends!
She’s already or not already, and so what
A very simple description of the variable "aaa" and an available algorithm for processing it:
var aaa ;
if ( aaa ) {
Res = 'I am!' ; // I AM!
} else {
Res = 'me no ...' ; // I'm not there
}
will give an obvious result: "I am not." Here's the value of the JavaScript function typeof = undefined. Just describing a variable means nothing at all. Of course, when aaa = 1, we get: “I AM!”, But if aaa = 0, then it will be as in the first case: “I am not ...”. A wonderful logic, a different mathematician, as well as a simple citizen, could not even think that a zero value has a completely different meaning than a real one. Only modern (atypical) programming is capable of such bold ideas!
JavaScript typeof construction, as well as a more intelligent expression if (aaa) {... x ...} else {... y ...}, has excellent consumer qualities and is very convenient to use.
About the features of Cyrillic and Latin
A professional programmer will always prefer the English character to Russian, sincerely thanks to that stage in the development of programming when cybernetics was not recognized in some spaces, but in other territories computer business has confidently gone uphill. Programming languages began to multiply and develop, taking as a basis of syntax 26 letters of the English alphabet and a set of other generally accepted characters.
Machine code became the simplest and most natural, it was beautiful, perfect, but specific to each architecture, and in high-level languages, the idea of portability between architectures immediately became relevant. This essentially contradicts the current moment: grounds for the JavaScript analogue typeof = undefined | string | number | boolean | object | function then simply did not exist. All languages were strictly formal, had strict syntax and did not allow ambiguity.
Types, Variables, and Their Use
The moment is very important. Typing and description of variables is the most important component of a program; a programmer cannot write a working algorithm until he puts the real variety of data into a strict formal picture of variables, arrays, objects and functions.
JavaScript carries all the functional power accumulated over decades; all of its constructions ideally reflect modern ideas about syntax and appropriate rules for putting semantics into it.
The question is when it should be done, when exactly it is necessary to define type text, JavaScript typeof function. Actually there are not many pure options for type text: a character, a string, and a number. However, the role of text can be played by an object, or even an array with the construction of array.join (), which combines all its elements into a single text, that is, on one line.
A banal statement: everything around is type text, and the JavaScript typeof function must perform the necessary type definition at the right time. This is so, but in practice everything turns out differently. JavaScript typeof object will return the same value in all three cases:
var aaa = {};
Res = typeof ( aaa );
Res + = '/' + typeof window . document ;
Res + = '/' + typeof ( document . Forms [ 0 ]);
result: object / object / object
Using the function can be in typeof (aaa) format and typeof aaa format - this is not essential, however, in all cases the answer is given, but it absolutely does not mean anything!
Uncertainty turns into certainty
Programming is characterized by a special dynamics: it flies so fast forward that the scale of movement is constantly expanding. The bill goes for months, weeks or days, and sometimes even for hours. In specific problems, the dynamics of the formation of the solution algorithm is so swift and demanding continuity that the programmer’s exit from the working state can discard the solution for a day, a week or a longer period.
The natural JavaScript typeof solution and the practice of object-oriented programming, which in this syntax is somewhat different from that in adjacent modern languages, transfers the center of gravity to the object. A very characteristic point: the language becomes a construct containing semantics, and not a set of syntactic norms.
Simple data types do not need to determine their type, or rather, using JavaScript typeof is enough. If necessary, the runtime itself takes care of the proper conversions, but with regard to JavaScript objects, typeof gives the most reasonable answer: this is an object and a problem of its type is its concern! Such logic for the classical idea of programming is difficult to perceive, but this is the real situation of the right things.
The concern of the object is to determine its type, to show its properties and perform its methods. Programming has refined its syntax and, with each moment of time, transfers the center of gravity from the syntax to the semantics formed by the programmer: a system of its objects that perform the task.