Introduction to JavaScript
Javascript is...
- Not Java nor Java-like
- A single-threaded, asynchronous (non-blocking), dynamically-typed, and weakly-typed language
- An imperative language (primitive language) with some functional-like aspects and OOPS feature (enhanced in ES6)
- An interpreted language
- Created by Brendan Eich at Netscape for its browser, Navigator
- JavaScript history names: Mocha -> LiveScript -> JavaScript -> ECMAScript
- In today's world, ECMAScript is a standard whereas JavaScript is an implementation (will talk more about ECMAScript later)
single-threaded
- There is one and only one thread called main thread handling tasks (what is a thread? think of it as worker in a factory)
- JavaScript has been traditionally known as a single-threaded language, but modern JavaScript is no longer single-threaded thanks to web worker and service worker.
- In the browser environment, what things are blocking?
- What could happen if code is blocking the browser?
- Async is the savior
Dynamic typing & weak typing
- Dynamic typing:
- Type is determined at runtime
- No need to specify type for a variable at declaration
- Weak typing:
- Type can be magically converted to another type at runtime
Imperative language
- A.k.a. primitive language
- JavaScript can also be functional and OOPS
Interpreted language
- Code is interpreted at runtime, meaning that a runtime engine (like Chrome v8) needs to parse and compile your source code before it can execute it
- Not performant compared to compiled language such as Go
- Stands for European Computer Manufacturer's Association
- A standard that specifies core features for JavaScript
- JavaScript is a well-known implementation of this standard
- History standards: ES3, ES5
- New standards: ES6 (a.k.a. ES2015)
- Primitive types: boolean, number, string, null, undefined, symbol (new in ES6)
- Object type: anything that is not primitive types, such as Array, Function
- Hoisting is JavaScript's default behavior of moving all variable declarations to the top of the current scope (to the top of the current script or the current function)
- A variable can be used before it has been declared
Coding Ninjas Bootcamp - Class 3: JavaScript
By Zico Deng
Coding Ninjas Bootcamp - Class 3: JavaScript
Introduction to JavaScript
- 100