Web development / design — some JS tricks explained

JavaScript can be tricky sometimes, whether you have other programming background or not. This page provides explanations of some JS tricks that often cause confusion for beginners.

(Click here to go back to the main page for web development related concepts and techniques.)

  • There is NO class concept in JS, not like Java / C++, it is prototype based (i.e., object based).
  • The primitive data in JS: string, number, boolean, and undefined; the complex data in JS: object, and function. So you may ask there is no array data structure in JS? JS does have array data structure, but it belongs to JS object (i.e., JS array is a type of JS object), there is no JS data type that is called array. (see here for more details.)
  • JS Scope (JS Scope — W3Schools) – a very good post well explained the scope of  JS function can be found at here (pdf)
  • JS Hosting (JavaScript Hoisting  — W3Schools)