Javascript

General look on language features

Built-in types

  • number
  • string
  • boolean
  • object
  • null
  • undefined
  • symbol (ES6)

...for all properties and methods of built-in types:

MDN is your friend:

https://developer.mozilla.org

Coercion

  • Explicit
    •  
  • Implicit
    •  
var a = Number('5')
var b = 5 + ''

Truthy and Falsy

Falsy values:

  • "" (empty string)
  • 0, -0, +0, NaN
  • null, undefined
  • false

truthy values:

anything except above

Equality

  • == (only value)
  • === (value and type)
  • !=  (only value)
  • !== (value and type)

Do not check equality of objects, arrays etc. with ==/===

It doesn't consider their values only reference

Function declaration

Function expression

function doSomething() {
    // ...doing something
}
var doSomething = function () {
    // ...doing something
}

vs

Immediately Invoked Function Expressions (IIFEs)

(function IIFE(){
	var a = 10;
	console.log( a );	// 10
})();


var x = (function IIFE2(){
	return 42;
})();

x;	// 42

"strict mode"

  • more optimized code
  • prevent auto-global variable
  • many more

Details are on next!

Javascript General

By Özgün Bal

Javascript General

  • 86