When JavaScript was created it's initial name was "LiveScript" with purpose to "make webpages alive". As JavaScript evolved it became a fully independent language, with its own specification called ECMAScript.
Recent versions are referenced by their ECMAScript version number(ES5, ES6). More recently the standards body has transitioned to a year-based number(ES2016, ES2017).
Use source attribute to attach script files to HTML. The benefit of having separate files(rather than writing the whole script directly in html) besides readability is that the browser will download it and then store in its cache. After this, other pages that want the same script will take it from the cache instead of downloading it. So the file is actually downloaded only once.
A single script tag can’t have both the src attribute and the code inside. A variable in JavaScript can contain any data. A variable can at one moment be a string and later receive a numeric value: Programming languages that allow such things are called "dynamically typed", meaning that there are data types, but variables are not bound to any of them.
There are 7 basic types in JavaScript.
Comparison of different types:
When compared values belong to different types, they are converted to numbers. A strict equality operator === checks the equality without type conversion. In other words, if a and b are of different types, then a === b immediately returns false without an attempt to convert them.
Recent versions are referenced by their ECMAScript version number(ES5, ES6). More recently the standards body has transitioned to a year-based number(ES2016, ES2017).
Use source attribute to attach script files to HTML. The benefit of having separate files(rather than writing the whole script directly in html) besides readability is that the browser will download it and then store in its cache. After this, other pages that want the same script will take it from the cache instead of downloading it. So the file is actually downloaded only once.
A single script tag can’t have both the src attribute and the code inside. A variable in JavaScript can contain any data. A variable can at one moment be a string and later receive a numeric value: Programming languages that allow such things are called "dynamically typed", meaning that there are data types, but variables are not bound to any of them.
There are 7 basic types in JavaScript.
- number for numbers of any kind: integer or floating-point.
- string for strings. A string may have one or more characters, there’s no separate single-character type.
- boolean for true/false.
- null for unknown values – a standalone type that has a single value null.
- undefined for unassigned values – a standalone type that has a single value undefined.
- object for more complex data structures.
- symbol for unique identifiers.
Primitive types: number, string, boolean, null, undefined
Type Conversions
Type Conversions
- ToString
- ToNumber
undefined → NaN
null → 0
true/false → 1/0
string → Whitespaces from the start and the end are removed. Then, if the remaining string is empty, the result is 0. Otherwise, the number is “read” from the string. An error gives NaN - ToBoolean
When compared values belong to different types, they are converted to numbers. A strict equality operator === checks the equality without type conversion. In other words, if a and b are of different types, then a === b immediately returns false without an attempt to convert them.
Comments
Post a Comment