Please enable JavaScript.
Coggle requires JavaScript to display documents.
Chapter 2 Surveying js (Functions (function awesomeFunction(coolThings){},…
Chapter 2 Surveying js
Functions
function awesomeFunction(coolThings){}
function declaration
identifier and function in compile time
var awesomeFunction = function(coolThings){};
function expression
identifier and function in runtime
js treats function as object value
can assigned to variable
=== triple equals
compare type and value
NaN === NaN //false
Use Number.isNaN(..) instead
Use Object.is(...) too
0 === -0 //true
Object.is(...)
doesnt use the two comparing above
object are compared reference in memory
== double equals
coercive equality
type conversion first
42 == "42" //true
1 == "true" //true
compare operator use coercion equality too
>, <, <=, >=
Patterns in js
Module
can access variable without this
example
https://codepen.io/RibeiroAmerico/pen/vYOXybL
Class
examples
class Publication{}
constructor(name) {
this.name = name;
}
https://codepen.io/RibeiroAmerico/pen/MWwjbzX
class must use this to access variables
store data and methods an object instance
ES Modules
created in a file