Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
340-CT/Javascript
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
88 lines (58 sloc)
2.94 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JavaScript is one of the 3 languages all web developers must learn: | |
1. HTML to define the content of web pages | |
2. CSS to specify the layout of web pages | |
3. JavaScript to program the behavior of web pages | |
Web pages are not the only place where JavaScript is used. Many desktop and server programs use JavaScript. | |
Node.js is the best known. Some databases, like MongoDB and CouchDB, also use JavaScript as their programming language. | |
JavaScript syntax is the set of rules, how JavaScript programs are constructed: | |
var x, y, z; // How to declare variables | |
x = 5; y = 6; // How to assign values | |
z = x + y; // How to compute values | |
JavaScript Values | |
The JavaScript syntax defines two types of values: Fixed values and variable values. | |
JavaScript Data Types | |
JavaScript variables can hold many data types: numbers, strings, objects and more: | |
var length = 16; // Number | |
var lastName = "Johnson"; // String | |
var x = {firstName:"John", lastName:"Doe"}; // Object | |
The Concept of Data Types | |
In programming, data types is an important concept. | |
To be able to operate on variables, it is important to know something about the type. | |
Fixed values are called literals. Variable values are called variables. | |
ECMAScript 2015 | |
ES6, also known as ECMAScript2015, introduced classes. | |
A class is a type of function, but instead of using the keyword function to initiate it, we use the keyword class, and the properties is assigned inside a constructor() method. | |
Class Definition | |
Use the keyword class to create a class, and always add a constructor method. | |
The constructor method is called each time the class object is initialized. | |
Example | |
A simple class definition for a class named "Car": | |
class Car { | |
constructor(brand) { | |
this.carname = brand; | |
} | |
} | |
Now you can create objects using the Car class: | |
Example | |
Create an object called "mycar" based on the Car class: | |
class Car { | |
constructor(brand) { | |
this.carname = brand; | |
} | |
} | |
mycar = new Car("Ford"); | |
JavaScript (JS) is a lightweight, interpreted, or just-in-time | |
compiled programming language with first-class functions. | |
While it is most well-known as the scripting language for Web pages, | |
many non-browser environments also use it, such as Node.js, Apache CouchDB and Adobe Acrobat. | |
JavaScript is a prototype-based, multi-paradigm, dynamic language, supporting object-oriented, | |
imperative, and declarative (e.g. functional programming) styles. Read more about JavaScript. | |
Standard objects | |
Get to know standard built-in objects Array, | |
Boolean, Date, Error, Function, JSON, Math, Number, Object, RegExp, String, Map, Set, WeakMap, WeakSet, and others. | |
Expressions and operators | |
Learn more about the behavior of JavaScript's operators instanceof, typeof, new, this, | |
the operator precedence, and more. | |
Statements and declarations | |
Learn how do-while, for-in, for-of, try-catch, let, var, | |
const, if-else, switch, and more JavaScript statements and keywords work. |