- JavaScript is interpreted as opposed to compiled
- C is compiled
- No need to declare variable types
- Allows dynamic typing : given a variable there is no type associated with it until it is filled with value, it can be changed later. Some languages are not
- ES6 is the latest version of JavaScript full name is ECMAScript 6
- Symbol
- In new JavaScript languages semicolon ; is likely optional
- JavaScript can check equality using double equal sign == , or triple equal sign ===
- == coerces the type
- === requires to be exact, doesn't coerce the type
- Node command line runtime for JavaScript is built on V8 engine
- typeof null --> returns object - one of those strange behaviors of JavaScript
- JavaScript development is guided by ECMAScript standard. ECMA is pronounced Ehk-MA. E stands for Europe
- You can think : the spec for JavaScript is written by ECMA
- Each browser can have its own JavaScript engine, for example Chrome uses V8
- Event Listener
- Listening or subscribing events such as keydown
- aka the =Event handler
- Modern JavaScript variations include Typescript, frequently used in Angular
- npm is the popular package manager for JavaScript
- Has joined Github
- In order words both Github and npm is now owned by Microsoft
- Define a constant : const CONSTANT = 0.5
- Enclose strings in double quotes or single quotes
- Arrays can contain values as well as functions
- const arr = ["value1",5, function(){console.log("Hello World")}]
- Run the function arr[2]()
- Can contain different types
- Can access using indexing, starting from position zero
- use array with for loop
for (let i = 0; i < arry.length : i++) {
console.log(arr[i])
}
- JavaScript allows trailing comma
- Types
- primitives:
- no methods attached? immutable
- boolean, string, null, number, symbol, undefined
- Number includes both float and integer, there is no separate type
- Sudden differences between undefined and null
- JavaScript string
- concatenation is implicit coercion or type casting, if we use str(variable) then that's explicit coercion
- checking types of input using typeof, e.g. typeof undefined // --> undefined, type 5 // --> number
- Try out JavaScript interactively using Chrome browser inspect element mode, or install node and call interactive JavaScript prompt. Use those two as a JavaScript interpreter
- In general, undefined is returned if nothing specific is returned
- JavaScript documentation by Mozilla https://developer.mozilla.org/en-US/docs/Web/javascript